/* Microsoft 365 / Fluent UI — ERP style */
:root {
    --sidebar-width: 228px;
    --fluent-blue: #0078d4;
    --fluent-blue-hover: #106ebe;
    --fluent-blue-light: #deecf9;
    --fluent-bg: #faf9f8;
    --fluent-surface: #ffffff;
    --fluent-border: #edebe9;
    --fluent-border-strong: #d2d0ce;
    --fluent-text: #242424;
    --fluent-text-secondary: #605e5c;
    --fluent-nav-hover: #f3f2f1;
    --fluent-nav-active: #e8f4fd;
    --fluent-shadow: 0 1.6px 3.6px rgba(0,0,0,.13), 0 0.3px 0.9px rgba(0,0,0,.11);
    --fluent-radius: 4px;
    --font-stack: 'Segoe UI', 'Segoe UI Web (West European)', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-stack);
    font-size: 14px;
    background: var(--fluent-bg);
    color: var(--fluent-text);
    -webkit-font-smoothing: antialiased;
}

.app-wrapper { display: flex; min-height: 100vh; }

/* —— Shell navigation (M365 left rail) —— */
.sidebar {
    width: var(--sidebar-width);
    background: var(--fluent-surface);
    border-right: 1px solid var(--fluent-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
}

.sidebar-brand {
    padding: 16px 16px 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--fluent-text);
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--fluent-border);
}

.sidebar-brand i {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--fluent-blue);
    color: #fff;
    border-radius: var(--fluent-radius);
    font-size: 16px;
}

.nav-section {
    padding: 8px 8px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fluent-text-secondary);
}

.sidebar-nav {
    flex: 1;
    padding: 4px 8px;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 2px;
    color: var(--fluent-text);
    text-decoration: none;
    border-radius: var(--fluent-radius);
    font-size: 14px;
    transition: background .1s;
}

.sidebar-nav a i {
    font-size: 16px;
    width: 20px;
    color: var(--fluent-text-secondary);
}

.sidebar-nav a:hover {
    background: var(--fluent-nav-hover);
}

.sidebar-nav a.active {
    background: var(--fluent-nav-active);
    color: var(--fluent-blue);
    font-weight: 600;
}

.sidebar-nav a.active i { color: var(--fluent-blue); }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--fluent-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    padding: 8px;
    border-radius: var(--fluent-radius);
    background: var(--fluent-bg);
}

.user-info i { font-size: 28px; color: var(--fluent-text-secondary); }
.user-info strong { display: block; font-size: 13px; }
.user-info small { color: var(--fluent-text-secondary); font-size: 12px; }

/* —— Main + command bar —— */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--fluent-surface);
    padding: 0 24px;
    min-height: 48px;
    border-bottom: 1px solid var(--fluent-border);
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar .page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--fluent-text);
    flex: 1;
    margin: 0;
    line-height: 48px;
}

.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.content-area {
    padding: 20px 24px 32px;
    flex: 1;
}

/* —— Cards & KPI tiles (Dynamics style) —— */
.stat-card {
    background: var(--fluent-surface);
    border: 1px solid var(--fluent-border);
    border-radius: var(--fluent-radius);
    padding: 16px 20px;
    box-shadow: none;
    height: 100%;
    transition: box-shadow .15s;
}

.stat-card:hover {
    box-shadow: var(--fluent-shadow);
}

.stat-card .stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--fluent-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--fluent-text);
    line-height: 1.2;
}

.stat-card.accent-blue { border-top: 3px solid var(--fluent-blue); }
.stat-card.accent-green { border-top: 3px solid #107c10; }
.stat-card.accent-orange { border-top: 3px solid #ca5010; }
.stat-card.accent-purple { border-top: 3px solid #5c2d91; }

.card-panel {
    background: var(--fluent-surface);
    border: 1px solid var(--fluent-border);
    border-radius: var(--fluent-radius);
    padding: 0;
    box-shadow: none;
    margin-bottom: 16px;
}

.card-panel-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--fluent-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-panel-header h5,
.card-panel-header h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.card-panel-body { padding: 16px 20px; }

.card-panel > h5:first-child {
    padding: 14px 20px;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--fluent-border);
}

.card-panel > .table-responsive,
.card-panel > form,
.card-panel > p { margin: 0; }
.card-panel > .table-responsive { padding: 0; }
.card-panel > p { padding: 16px 20px; }
.card-panel > form { padding: 16px 20px; }

/* —— Tables (ERP grid) —— */
.table {
    margin-bottom: 0;
    font-size: 13px;
}

.table thead th {
    background: var(--fluent-bg);
    border-bottom: 1px solid var(--fluent-border-strong);
    color: var(--fluent-text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: none;
    padding: 10px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--fluent-border);
    vertical-align: middle;
}

.table tbody tr:hover {
    background: #f8f8f8;
}

.table-hover tbody tr:hover { background: #f3f2f1; }

/* —— Buttons (Fluent) —— */
.btn {
    border-radius: var(--fluent-radius);
    font-size: 14px;
    font-weight: 600;
    padding: 5px 16px;
    min-height: 32px;
}

.btn-primary {
    background: var(--fluent-blue);
    border-color: var(--fluent-blue);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--fluent-blue-hover);
    border-color: var(--fluent-blue-hover);
}

.btn-outline-primary {
    color: var(--fluent-blue);
    border-color: var(--fluent-border-strong);
    background: var(--fluent-surface);
}

.btn-outline-primary:hover {
    background: var(--fluent-nav-hover);
    border-color: var(--fluent-border-strong);
    color: var(--fluent-blue-hover);
}

.btn-outline-secondary {
    border-color: var(--fluent-border-strong);
    color: var(--fluent-text);
    background: var(--fluent-surface);
}

.btn-sm {
    min-height: 28px;
    padding: 2px 12px;
    font-size: 13px;
}

/* —— Forms —— */
.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--fluent-text);
    margin-bottom: 4px;
}

.form-control,
.form-select {
    border-radius: var(--fluent-radius);
    border: 1px solid var(--fluent-border-strong);
    font-size: 14px;
    min-height: 32px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--fluent-blue);
    box-shadow: 0 0 0 1px var(--fluent-blue);
}

/* —— Alerts —— */
.alert {
    border-radius: var(--fluent-radius);
    border: none;
    font-size: 13px;
}

.alert-success { background: #dff6dd; color: #107c10; }
.alert-danger { background: #fde7e9; color: #a4262c; }
.alert-warning { background: #fff4ce; color: #797775; }
.alert-info { background: var(--fluent-blue-light); color: var(--fluent-blue); }

/* —— Badges (Fluent pills) —— */
.badge {
    font-weight: 600;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 2px;
}

.badge.bg-secondary { background: #edebe9 !important; color: #323130 !important; }
.badge.bg-primary { background: var(--fluent-blue-light) !important; color: var(--fluent-blue) !important; }
.badge.bg-success { background: #dff6dd !important; color: #107c10 !important; }
.badge.bg-warning { background: #fff4ce !important; color: #8a6914 !important; }
.badge.bg-danger { background: #fde7e9 !important; color: #a4262c !important; }
.badge.bg-info { background: #e5f3ff !important; color: #0078d4 !important; }

/* —— Login (Microsoft sign-in) —— */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--fluent-bg);
}

.login-shell {
    display: flex;
    width: 100%;
    max-width: 960px;
    min-height: 560px;
    margin: 24px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--fluent-shadow);
    border: 1px solid var(--fluent-border);
}

.login-hero {
    flex: 1;
    background: linear-gradient(160deg, #0078d4 0%, #004578 100%);
    color: #fff;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-hero h1 { font-size: 28px; font-weight: 600; margin-bottom: 12px; }
.login-hero p { opacity: 0.9; font-size: 15px; line-height: 1.5; }

.login-card {
    flex: 1;
    background: var(--fluent-surface);
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-card h2 { font-size: 24px; font-weight: 600; margin-bottom: 8px; }

/* —— FullCalendar tweak —— */
.fc {
    font-family: var(--font-stack);
    font-size: 13px;
}

.fc .fc-button-primary {
    background: var(--fluent-surface) !important;
    border-color: var(--fluent-border-strong) !important;
    color: var(--fluent-text) !important;
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
    background: var(--fluent-nav-active) !important;
    color: var(--fluent-blue) !important;
}

.fc-theme-standard td, .fc-theme-standard th {
    border-color: var(--fluent-border);
}

/* —— Utility —— */
.text-muted { color: var(--fluent-text-secondary) !important; }

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--fluent-shadow); }
    .main-content { margin-left: 0; }
    .login-shell { flex-direction: column; }
    .login-hero { padding: 32px 24px; }
}

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin: 0; }
}
