/* ============================================================
   SMS Manager — Feuille de style principale
   Palette: fond sombre charbon + accents violet/indigo
   ============================================================ */

:root {
    --bg:        #0f1117;
    --bg2:       #181c27;
    --bg3:       #1e2336;
    --border:    #2a2f45;
    --text:      #e8eaf0;
    --text-muted:#7a82a0;
    --accent:    #6366f1;
    --accent2:   #818cf8;
    --success:   #10b981;
    --danger:    #ef4444;
    --warning:   #f59e0b;
    --sidebar-w: 240px;
    --radius:    10px;
}

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

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

a { color: inherit; text-decoration: none; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    transition: transform .25s ease;
    z-index: 100;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.page-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

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

.brand-name {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -.01em;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem .75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.nav-section {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.nav-label {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-muted);
    padding: 0 .5rem;
    margin-bottom: .25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .5rem .75rem;
    border-radius: 7px;
    color: var(--text-muted);
    font-size: .875rem;
    transition: background .15s, color .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }

.dept-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: .75rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: .625rem;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 32px; height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: .8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.btn-logout {
    width: 30px; height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-muted);
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.btn-logout:hover { background: var(--danger); color: #fff; }

/* ============================================================
   TOP BAR
   ============================================================ */
.top-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .75rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: .25rem;
}

.page-title {
    font-family: 'Syne', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    flex: 1;
}

.top-bar-right { display: flex; align-items: center; gap: .75rem; }

.sms-badge {
    display: flex;
    align-items: center;
    gap: .375rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    padding: .3rem .75rem;
    border-radius: 20px;
    font-size: .75rem;
    color: var(--text-muted);
}

/* ============================================================
   CARDS & COMPONENTS
   ============================================================ */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.card-title {
    font-family: 'Syne', sans-serif;
    font-size: 1rem;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    transition: border-color .2s;
}
.stat-card:hover { border-color: var(--accent); }

.stat-value {
    font-family: 'Syne', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
}

.stat-label { font-size: .8rem; color: var(--text-muted); }

.stat-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .25rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1rem;
    border-radius: 7px;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all .15s;
    white-space: nowrap;
}

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .85; }
.btn-ghost     { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm        { padding: .3rem .75rem; font-size: .8rem; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; margin-bottom: .4rem; font-size: .8rem; font-weight: 500; color: var(--text-muted); }
.form-control {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: .6rem .875rem;
    color: var(--text);
    font-family: inherit;
    font-size: .875rem;
    transition: border-color .15s;
    outline: none;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-muted); }

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

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    padding: .625rem 1rem;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: .875rem;
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ============================================================
   BADGES & ALERTS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
}
.badge-success  { background: rgba(16,185,129,.15); color: var(--success); }
.badge-danger   { background: rgba(239,68,68,.15);  color: var(--danger);  }
.badge-warning  { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-info     { background: rgba(99,102,241,.15); color: var(--accent2); }
.badge-admin    { background: rgba(99,102,241,.2);  color: var(--accent2); }
.badge-user     { background: var(--bg3); color: var(--text-muted); }

.alert {
    padding: .875rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
    display: flex;
    align-items: flex-start;
    gap: .5rem;
}
.alert-success { background: rgba(16,185,129,.1);  border: 1px solid rgba(16,185,129,.3);  color: var(--success); }
.alert-danger  { background: rgba(239,68,68,.1);   border: 1px solid rgba(239,68,68,.3);   color: var(--danger);  }
.alert-warning { background: rgba(245,158,11,.1);  border: 1px solid rgba(245,158,11,.3);  color: var(--warning); }
.alert-info    { background: rgba(99,102,241,.1);  border: 1px solid rgba(99,102,241,.3);  color: var(--accent2); }

/* ============================================================
   DEPT PAGE - SMS FORM
   ============================================================ */
.dept-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.dept-color-bar {
    width: 6px;
    height: 48px;
    border-radius: 4px;
    flex-shrink: 0;
}

.dept-title {
    font-family: 'Syne', sans-serif;
    font-size: 1.3rem;
    font-weight: 800;
}

.dept-desc { font-size: .875rem; color: var(--text-muted); }

.two-col { display: grid; grid-template-columns: 1fr 1.2fr; gap: 1.5rem; }

.char-count { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; text-align: right; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 60% at 20% 40%, rgba(99,102,241,.08) 0%, transparent 60%),
        radial-gradient(ellipse 60% 80% at 80% 60%, rgba(129,140,248,.06) 0%, transparent 60%);
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo .brand-icon {
    width: 52px; height: 52px;
    margin: 0 auto 1rem;
    border-radius: 14px;
}

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

.login-logo p { font-size: .875rem; color: var(--text-muted); }

/* ============================================================
   PERMISSION MATRIX
   ============================================================ */
.perm-matrix { width: 100%; border-collapse: collapse; }
.perm-matrix th, .perm-matrix td { padding: .625rem .875rem; border-bottom: 1px solid var(--border); font-size: .875rem; }
.perm-matrix tr:hover td { background: var(--bg3); }

.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 22px;
    cursor: pointer;
    transition: .2s;
}
.toggle-slider:before {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    left: 3px; top: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); background: #fff; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .page-body { padding: 1rem; }
    .two-col { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .top-bar { padding: .75rem 1rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
