/* ============================================================
   MGS Connect — Portail Maintenance
   Style : Industriel / Technique / Sombre raffiné
   Fonts : Syne (titres) + DM Sans (corps)
   ============================================================ */

/* ── Palettes HSL ─────────────────────────────────────────── */
* {
    --brand-hue:        200;
    --brand-saturation: 100%;
    --brand-lightness:  50%;

    --brand-light:    hsl(200 100% 50%);
    --text1-light:    hsl(200 100% 10%);
    --text2-light:    hsl(200 30%  30%);
    --surface1-light: hsl(200 25%  90%);
    --surface2-light: hsl(200 20%  99%);
    --surface3-light: hsl(200 20%  92%);
    --surface4-light: hsl(200 20%  85%);

    --brand-dark:     hsl(200 50% 33%);
    --text1-dark:     hsl(200 15% 85%);
    --text2-dark:     hsl(200 5%  65%);
    --surface1-dark:  hsl(200 10% 10%);
    --surface2-dark:  hsl(200 10% 15%);
    --surface3-dark:  hsl(200 5%  20%);
    --surface4-dark:  hsl(200 5%  25%);

    --brand-dim:      hsl(200 80% 40%);
    --text1-dim:      hsl(200 15% 75%);
    --text2-dim:      hsl(200 10% 61%);
    --surface1-dim:   hsl(200 10% 20%);
    --surface2-dim:   hsl(200 10% 25%);
    --surface3-dim:   hsl(200 5%  30%);
    --surface4-dim:   hsl(200 5%  35%);
}

/* ── Thème par défaut : Dark ──────────────────────────────── */
:root {
    --bg-base:        #0d0f14;
    --bg-surface:     #13161e;
    --bg-elevated:    #1a1e29;
    --bg-hover:       #202433;
    --border:         #252a38;
    --border-light:   #2e3447;

    --text-primary:   #eef0f6;
    --text-secondary: #8b91a8;
    --text-muted:     #555c73;

    --accent:         #3b82f6;
    --accent-hover:   #2563eb;
    --accent-glow:    rgba(59, 130, 246, 0.15);

    --success:        #22c55e;
    --warning:        #f59e0b;
    --danger:         #ef4444;
    --info:           #06b6d4;

    --sidebar-w:      260px;
    --radius:         10px;
    --radius-sm:      6px;
    --shadow:         0 4px 24px rgba(0,0,0,0.4);
}

/* ── Thème Light — doit être APRÈS :root ──────────────────── */
html[color-scheme="light"] {
    --bg-base:        var(--surface1-light);
    --bg-surface:     var(--surface2-light);
    --bg-elevated:    var(--surface3-light);
    --bg-hover:       var(--surface4-light);
    --border:         hsl(200 20% 80%);
    --border-light:   hsl(200 20% 75%);
    --text-primary:   var(--text1-light);
    --text-secondary: var(--text2-light);
    --text-muted:     hsl(200 15% 55%);
    --accent:         hsl(200 100% 38%);
    --accent-hover:   hsl(200 100% 28%);
    --accent-glow:    rgba(0, 136, 204, 0.15);
    --shadow:         0 4px 24px rgba(0, 80, 120, 0.12);
}

/* ── Thème Dim — doit être APRÈS :root ───────────────────── */
html[color-scheme="dim"] {
    --bg-base:        var(--surface1-dim);
    --bg-surface:     var(--surface2-dim);
    --bg-elevated:    var(--surface3-dim);
    --bg-hover:       var(--surface4-dim);
    --border:         hsl(200 10% 30%);
    --border-light:   hsl(200 10% 35%);
    --text-primary:   var(--text1-dim);
    --text-secondary: var(--text2-dim);
    --text-muted:     hsl(200 8% 50%);
    --accent:         hsl(200 80% 48%);
    --accent-hover:   hsl(200 80% 38%);
    --accent-glow:    rgba(0, 120, 200, 0.15);
    --shadow:         0 4px 24px rgba(0, 0, 0, 0.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: 'DM Sans', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 40px; height: 40px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.brand-name {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 15px;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-menu {
    list-style: none;
    padding: 16px 0;
    flex: 1;
}

.nav-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 16px 20px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 400;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.nav-link i { width: 16px; text-align: center; font-size: 13px; }

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-left-color: var(--border-light);
}

.nav-link.active {
    background: var(--accent-glow);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.user-avatar {
    width: 34px; height: 34px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 15px;
    text-decoration: none;
    transition: color 0.15s;
}
.logout-btn:hover { color: var(--danger); }

/* ── MAIN CONTENT ─────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 32px 0;
    gap: 16px;
}

.page-title {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 24px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.page-body {
    padding: 24px 32px 40px;
    flex: 1;
}

/* ── CARDS ────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-title {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i { color: var(--accent); }

/* ── STAT CARDS ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color 0.2s;
}

.stat-card:hover { border-color: var(--accent); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.blue   { background: rgba(59,130,246,0.15); color: var(--accent); }
.stat-icon.green  { background: rgba(34,197,94,0.15);  color: var(--success); }
.stat-icon.orange { background: rgba(245,158,11,0.15); color: var(--warning); }
.stat-icon.red    { background: rgba(239,68,68,0.15);  color: var(--danger); }

.stat-value {
    font-family: 'Syne', sans-serif;
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ── TABLES ───────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 16px;
    text-align: left;
    white-space: nowrap;
}

tbody tr {
    border-top: 1px solid var(--border);
    transition: background 0.1s;
}

tbody tr:hover { background: var(--bg-hover); }

tbody td {
    padding: 13px 16px;
    color: var(--text-primary);
    font-size: 13.5px;
    vertical-align: middle;
}

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.badge-ouvert   { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-encours  { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-resolu   { background: rgba(34,197,94,0.15);  color: #4ade80; }
.badge-ferme    { background: rgba(107,114,128,0.15);color: #9ca3af; }

.badge-basse    { background: rgba(107,114,128,0.15);color: #9ca3af; }
.badge-normale  { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-haute    { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-urgente  { background: rgba(239,68,68,0.18);  color: #f87171; border: 1px solid rgba(239,68,68,0.3); }

.garantie-ok      { color: var(--success); font-size: 12px; font-weight: 600; }
.garantie-bientot { color: var(--warning); font-size: 12px; font-weight: 600; }
.garantie-expire  { color: var(--danger);  font-size: 12px; font-weight: 600; }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-danger {
    background: rgba(239,68,68,0.12);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── FORMS ────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 7px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    padding: 10px 14px;
    outline: none;
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea { resize: vertical; min-height: 100px; }
select { cursor: pointer; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── ALERTS ───────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #4ade80; }
.alert-danger  { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
.alert-warning { background: rgba(245,158,11,0.12);border: 1px solid rgba(245,158,11,0.3);color: #fbbf24; }

/* ── GRID LAYOUTS ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.flex   { display: flex; }
.items-center { align-items: center; }
.gap-3  { gap: 12px; }
.ml-auto{ margin-left: auto; }

/* ── TICKET THREAD ────────────────────────────────────────── */
.thread { display: flex; flex-direction: column; gap: 12px; }

.thread-msg {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
}

.thread-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.thread-meta strong { color: var(--text-primary); font-size: 13px; }

/* ── LOGIN PAGE ───────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(59,130,246,0.04) 0%, transparent 50%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .brand-icon {
    width: 56px; height: 56px;
    margin: 0 auto 12px;
    font-size: 24px;
}

.login-logo h1 {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 22px;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* ── ROOM CARD ────────────────────────────────────────────── */
.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.room-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.room-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.2s;
}

.room-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.room-card:hover::before { opacity: 1; }

.room-name {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 6px;
}

.room-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
}

.room-stats {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.room-stat { flex: 1; text-align: center; }

.room-stat-val {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 20px;
}

.room-stat-lbl {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
