/* ==============================
   ALSEN CHAT - BLUE WHITE MODERN
   Global UI for dashboard/admin/login
   ============================== */
:root {
    --wa-header: #1565c0;
    --wa-header-dark: #0b4a99;
    --wa-header-soft: #eaf4ff;
    --wa-green: #22c55e;
    --wa-bubble: #dbeafe;
    --wa-bg: #f3f7ff;
    --wa-panel: #eef5ff;
    --surface: #ffffff;
    --text: #111827;
    --muted: #667085;
    --border: #dbe7f7;
    --danger: #dc2626;
    --blue: #2563eb;
    --shadow: 0 16px 36px rgba(15, 74, 153, .08);
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f4f8ff;
    color: var(--text);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
body { overflow-x: hidden; }
a { color: inherit; }
img { max-width: 100%; height: auto; }

/* Topbar */
.wa-topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: calc(12px + env(safe-area-inset-top)) 16px 0;
    background: linear-gradient(135deg, #0b4a99 0%, #1565c0 58%, #2f80ed 100%);
    color: #fff;
    box-shadow: 0 10px 28px rgba(21,101,192,.20);
}
.wa-brand-row {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.wa-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-weight: 900;
    letter-spacing: .2px;
    font-size: 20px;
    min-width: 0;
}
.wa-brand img,
.dashboard-logo,
.logo-app,
.app-logo {
    width: 42px !important;
    height: 42px !important;
    max-width: 42px !important;
    max-height: 42px !important;
    object-fit: contain !important;
    border-radius: 50%;
    background: #fff;
    padding: 3px;
    flex-shrink: 0;
    display: block;
}
.wa-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-user-mini {
    font-size: 13px;
    text-align: right;
    line-height: 1.25;
    opacity: .95;
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wa-user-mini small { display: block; opacity: .78; font-size: 11px; }
.wa-tabs {
    width: 100%;
    max-width: 1180px;
    margin: 12px auto 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 10px;
}
.wa-tabs::-webkit-scrollbar { display: none; }
.wa-tabs a {
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    padding: 9px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.14);
    white-space: nowrap;
    font-weight: 800;
}
.wa-tabs a.active { background: #fff; color: #0b4a99; box-shadow: 0 6px 16px rgba(0,0,0,.12); }
.wa-tabs .danger-link { background: rgba(239,68,68,.96); color:#fff; }
.navbar { display: none !important; }

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px;
}
.site-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 18px; }
.card, .wa-home-card, .wa-list-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.card-title { margin: 0 0 14px; color: var(--wa-header-dark); font-size: 18px; }

.wa-home-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(135deg,#fff,#f4f9ff);
}
.wa-greeting { font-size: 22px; font-weight: 900; color: var(--wa-header-dark); }
.wa-greeting-sub { margin-top: 6px; color: var(--muted); font-size: 14px; }
.wa-panel-title { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px; }
.wa-panel-title h2 { margin:0; font-size:20px; color:var(--wa-header-dark); }
.wa-panel-title span { color:var(--muted); font-size:13px; }

/* Contact list */
.wa-contact-list { display:flex; flex-direction:column; }
.wa-contact {
    display:flex;
    align-items:center;
    gap:12px;
    text-decoration:none;
    padding:12px 4px;
    border-bottom:1px solid var(--border);
    transition: background .15s ease, padding .15s ease;
}
.wa-contact:last-child { border-bottom: none; }
.wa-contact:hover { background:#f4f9ff; border-radius:12px; padding-left:8px; padding-right:8px; }
.wa-contact-avatar {
    width:50px;
    height:50px;
    border-radius:50%;
    background:linear-gradient(135deg,#1565c0,#60a5fa);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:900;
    font-size:20px;
    flex-shrink:0;
}
.wa-contact-main { min-width:0; flex:1; }
.wa-contact-top, .wa-contact-bottom { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.wa-contact-name { font-weight:900; font-size:16px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.wa-contact-time { color:var(--muted); font-size:12px; flex-shrink:0; }
.wa-contact-preview { color:var(--muted); font-size:13px; margin-top:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.wa-unread { min-width:22px; height:22px; padding:0 7px; border-radius:999px; background:var(--wa-header); color:#fff; display:inline-flex; align-items:center; justify-content:center; font-size:12px; font-weight:900; flex-shrink:0; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; background:#aebac1; vertical-align: -1px; }
.status-online { background: var(--wa-green); box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.status-offline { background: #aebac1; }

/* Generic form/table/admin */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-6 { grid-column: span 6; } .col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }
.form-group { margin-bottom: 12px; }
label { display:block; margin-bottom: 6px; font-size: 13px; font-weight: 800; color: #344054; }
.form-control, select, textarea, input[type="text"], input[type="password"], input[type="number"] { width: 100%; border: 1px solid #d1d7db; border-radius: 10px; padding: 10px 12px; font: inherit; outline: none; background: #fff; }
.form-control:focus, select:focus, textarea:focus, input:focus { border-color: #2f80ed !important; box-shadow: 0 0 0 4px rgba(47,128,237,.12) !important; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 20px; padding: 10px 15px; font-weight: 900; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--wa-header); border-color: var(--wa-header); color: #fff; box-shadow: 0 8px 18px rgba(21,101,192,.18); }
.btn-primary:hover { background:#0b4a99; border-color:#0b4a99; }
.btn-light { background: #e8f2ff; color: var(--wa-header-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.alert { padding: 11px 13px; border-radius: 12px; margin-bottom: 14px; font-size: 13px; }
.alert-success { background: #e7f7ee; color: #146c43; }
.alert-danger { background: #ffebee; color: #b71c1c; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #f0f6ff; color: #0b4a99; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
tr:last-child td { border-bottom: none; }
.badge { display:inline-flex; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 900; background: #e8f2ff; color: var(--wa-header-dark); }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 14px; }
.tabs a { text-decoration: none; padding: 9px 13px; border-radius: 999px; background: #e9edef; color: #3b4a54; font-size: 13px; font-weight: 900; white-space: nowrap; }
.tabs a.active { background: var(--wa-header); color: white; }

/* Login */
.login-page { min-height: 100vh; min-height: 100dvh; display:flex; align-items:center; justify-content:center; padding: 18px; background: radial-gradient(circle at top left, rgba(66,153,225,.22), transparent 30%), linear-gradient(135deg, #eaf4ff 0%, #ffffff 45%, #dbeafe 100%); }
.login-card { width:100%; max-width: 430px; background:#fff; border-radius: 22px; padding: 28px; border:1px solid rgba(21,101,192,.12); box-shadow:0 24px 70px rgba(15,74,153,.18); }
.login-logo { text-align:center; margin-bottom: 20px; }
.login-logo img, .login-page img { display:block; height:84px !important; width:auto !important; max-width:120px !important; object-fit: contain; margin:0 auto 12px; }
.login-logo h1 { margin: 10px 0 4px; color: var(--wa-header-dark); font-size: 24px; }
.login-logo p { margin: 0; color: var(--muted); font-size: 13px; }
.install-card { background:#edf6ff!important; border-color:rgba(21,101,192,.18)!important; color:#0b4a99!important; }
.install-card strong{color:#1565c0!important}

@media (max-width: 768px) {
    .wa-topbar { padding-left:12px; padding-right:12px; }
    .wa-brand span { font-size:18px; }
    .wa-brand img { width:38px!important; height:38px!important; max-width:38px!important; max-height:38px!important; }
    .wa-user-mini { display:none; }
    .container { padding: 10px; }
    .grid { grid-template-columns: 1fr; }
    .col-3, .col-4, .col-6, .col-8, .col-12 { grid-column: auto; }
    .card, .wa-home-card, .wa-list-panel { border-radius: 15px; padding: 14px; }
    .wa-greeting { font-size:20px; }
    .wa-contact-avatar { width:46px; height:46px; }
}


/* Admin import polish */
.admin-hero {
    background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(240,247,255,.92));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 22px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.admin-hero h1,
.admin-hero h2,
.admin-hero h3 {
    margin: 0 0 6px;
    color: var(--wa-header-dark);
}
.admin-hero p { margin: 0; color: var(--muted); }
.admin-tabs, .tabs {
    align-items: center;
}
.import-panel {
    padding: 22px;
}
.import-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.import-title {
    margin: 0 0 6px;
    color: var(--wa-header-dark);
    font-size: 22px;
    font-weight: 900;
}
.import-desc {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
    max-width: 850px;
}
.template-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 14px 0 20px;
}
.import-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.35fr) auto;
    gap: 14px;
    align-items: end;
    padding: 16px;
    background: #f8fbff;
    border: 1px solid var(--border);
    border-radius: 16px;
}
.import-form .form-group { margin-bottom: 0; }
.import-form input[type="file"].form-control {
    min-height: 45px;
    padding: 8px 10px;
}
.import-form .btn {
    min-height: 45px;
    border-radius: 13px;
    padding-left: 22px;
    padding-right: 22px;
}
.admin-note {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}
@media (max-width: 900px) {
    .import-form { grid-template-columns: 1fr; }
    .import-form .btn { width: 100%; }
    .import-head { flex-direction: column; }
}

/* Import layout polish */
.import-panel{padding:22px!important;}
.import-title{font-size:20px;margin:0 0 8px;color:#0b4a99;font-weight:900;}
.import-desc{max-width:940px;color:#475569;line-height:1.55;margin:0 0 14px;}
.import-form{display:grid;grid-template-columns:minmax(220px,1fr) minmax(260px,1.5fr) auto;gap:14px;align-items:end;margin-top:8px;}
.import-form .form-group{margin:0;}
.import-form button[type="submit"]{min-height:44px;border-radius:999px;padding-left:22px;padding-right:22px;box-shadow:0 12px 24px rgba(21,101,192,.18);}
.import-form button[disabled]{opacity:.75;cursor:wait;}
.import-help{grid-column:1 / -1;color:#64748b;font-size:12px;margin-top:-4px;}
.template-actions{display:flex;gap:10px;flex-wrap:wrap;margin:10px 0 18px;}
.template-actions .btn{min-height:40px;}
@media(max-width:768px){.import-form{grid-template-columns:1fr}.import-form button[type="submit"]{width:100%;}.wa-brand-row{align-items:flex-start}.wa-user-mini{display:none}}


/* Teacher/walas contact grouping */
.teacher-panel-title{align-items:flex-start;gap:14px;flex-wrap:wrap;}
.chat-filter-buttons{display:flex;gap:10px;align-items:center;flex-wrap:wrap;}
.chat-filter-btn{border:1px solid var(--border);background:#eaf3ff;color:#0b4a99;border-radius:999px;padding:10px 18px;font-weight:900;cursor:pointer;box-shadow:0 6px 14px rgba(15,74,153,.06);}
.chat-filter-btn.active{background:#1565c0;color:#fff;border-color:#1565c0;box-shadow:0 10px 22px rgba(21,101,192,.18);}
.chat-contact-panel{display:none;}
.chat-contact-panel.active{display:block;}
.wa-contact-number{width:30px;height:30px;border-radius:999px;background:#eef5ff;color:#0b4a99;font-weight:900;font-size:13px;display:flex;align-items:center;justify-content:center;flex:0 0 30px;border:1px solid #dbe7f7;}
.contact-student-meta{color:#64748b;}
.reset-hint{display:inline-flex;align-items:center;min-height:36px;padding:0 10px;border-radius:999px;background:#f1f5f9;color:#475569;font-size:12px;font-weight:800;white-space:nowrap;}
@media(max-width:768px){.teacher-panel-title{flex-direction:column}.chat-filter-buttons{width:100%;}.chat-filter-btn{flex:1}.wa-contact-number{width:26px;height:26px;font-size:12px;}.contact-student-meta{display:block;margin-top:2px}}


/* Final logo and layout guardrails */
.wa-brand img,
.dashboard-logo,
.logo-app,
.app-logo,
.login-logo img,
.login-page img {
    object-fit: contain !important;
}
body > img:not(.allow-full-image) {
    max-width: 92px !important;
    max-height: 92px !important;
    width: auto !important;
    height: auto !important;
}

/* Account, password visibility, and device usage */
.account-page-grid{display:grid;grid-template-columns:minmax(300px,.9fr) minmax(340px,1.1fr);gap:16px;align-items:start;max-width:1100px;margin:20px auto;}
.account-page-grid .card{margin:0;}
.password-field-wrap{position:relative;display:flex;align-items:center;}
.password-field-wrap .form-control{padding-right:52px;}
.password-eye{position:absolute;right:7px;top:50%;transform:translateY(-50%);width:38px;height:36px;border:0;border-radius:9px;background:transparent;color:#64748b;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:background .15s ease,color .15s ease;}
.password-eye:hover{background:#f1f5f9;color:#0b4a99;}
.password-eye:focus{outline:none;box-shadow:0 0 0 3px rgba(47,128,237,.13);}
.password-eye .password-eye-svg{display:block;width:22px;height:22px;fill:none;stroke:#526174;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;pointer-events:none;}
.device-summary-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:14px;}
.device-count-badge{min-width:94px;padding:10px 12px;border-radius:16px;background:linear-gradient(135deg,#0b4a99,#2f80ed);color:#fff;text-align:center;box-shadow:0 10px 24px rgba(21,101,192,.18);}
.device-count-badge strong{display:block;font-size:26px;line-height:1;}
.device-count-badge span{display:block;font-size:11px;margin-top:4px;font-weight:800;}
.account-accuracy-note,.empty-device-state{padding:12px 14px;border-radius:13px;background:#f8fbff;border:1px solid #dbe7f7;color:#526174;font-size:12px;line-height:1.55;margin-bottom:12px;}
.device-list{display:flex;flex-direction:column;gap:10px;}
.device-item{display:flex;gap:12px;align-items:flex-start;padding:12px;border:1px solid #e2e8f0;border-radius:14px;background:#fff;}
.device-icon{width:38px;height:38px;border-radius:12px;background:#eaf3ff;color:#1565c0;display:flex;align-items:center;justify-content:center;font-size:18px;flex:0 0 38px;}
.device-main{min-width:0;flex:1;}
.device-title{font-weight:900;color:#172033;display:flex;align-items:center;gap:7px;flex-wrap:wrap;}
.device-meta{font-size:12px;color:#64748b;margin-top:4px;}
@media(max-width:820px){.account-page-grid{grid-template-columns:1fr;margin:10px auto}.device-summary-head{align-items:center}.account-password-card,.account-device-card{padding:16px!important}}
