/* =====================================================
   The Special One - Professional Educational UI
   Responsive: Desktop + Mobile
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

:root {
    --brand: #0d9488;
    --brand-dark: #0f766e;
    --brand-light: #ccfbf1;
    --accent: #f59e0b;
    --accent-2: #3b82f6;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f0fdfa;
    --card: #ffffff;
    --text: #134e4a;
    --muted: #5eead4;
    --sidebar-w: 270px;
    --radius: 18px;
    --shadow: 0 8px 24px rgba(13, 148, 136, 0.12);
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Cairo', Tahoma, sans-serif;
    background:
        radial-gradient(circle at 10% 10%, #a5f3fc 0%, transparent 40%),
        radial-gradient(circle at 90% 0%, #fde68a 0%, transparent 35%),
        radial-gradient(circle at 80% 80%, #bbf7d0 0%, transparent 40%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
    margin: 0;
    padding-bottom: 80px;
}
@media (max-width: 991.98px) {
    body {
        background: var(--bg);
    }
}

/* Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #0f766e 0%, #115e59 55%, #134e4a 100%);
    color: #fff;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}
.sidebar-brand {
    padding: 1.25rem;
    display: flex;
    gap: 12px;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    position: relative;
}
.sidebar-brand h1 {
    font-size: 1.1rem;
    margin: 0;
    font-weight: 800;
    letter-spacing: 0.3px;
}
.sidebar-brand p {
    margin: 0;
    font-size: 0.72rem;
    opacity: 0.85;
}
.logo-circle {
    width: 48px; height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    display: grid; place-items: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 12px rgba(245,158,11,0.4);
    flex-shrink: 0;
}
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.85rem 1rem;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    border-radius: 14px;
    margin-bottom: 4px;
    font-weight: 600;
    transition: all 0.2s;
}
.nav-item i { font-size: 1.2rem; width: 24px; text-align: center; }
.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    transform: translateX(-3px);
}
.nav-item.active {
    background: linear-gradient(90deg, rgba(251,191,36,0.35), rgba(255,255,255,0.1));
    box-shadow: inset 3px 0 0 #fbbf24;
}
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.12);
    font-size: 0.9rem;
}
.phone-line { opacity: 0.95; }

.main-content {
    flex: 1;
    margin-right: var(--sidebar-w);
    padding: 1.5rem;
    width: 100%;
    max-width: 100%;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}
.page-header h2 {
    font-weight: 800;
    margin: 0;
    color: var(--brand-dark);
}
.header-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.user-chip, .date-chip {
    background: #fff;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-size: 0.85rem;
    box-shadow: var(--shadow-sm);
}

/* Cards */
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: none;
    height: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(13,148,136,0.18); }
.stat-card .icon {
    width: 52px; height: 52px;
    border-radius: 16px;
    display: grid; place-items: center;
    font-size: 1.4rem;
    color: #fff;
    margin-bottom: 0.75rem;
}
.stat-card .value {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.1;
}
.stat-card .label {
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 600;
}
.icon-teal { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.icon-green { background: linear-gradient(135deg, #4ade80, #16a34a); }
.icon-red { background: linear-gradient(135deg, #f87171, #dc2626); }
.icon-amber { background: linear-gradient(135deg, #fbbf24, #d97706); }
.icon-blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.icon-purple { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.icon-pink { background: linear-gradient(135deg, #f472b6, #db2777); }

.panel {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(13,148,136,0.08);
}
.panel-title {
    font-weight: 800;
    font-size: 1.15rem;
    margin-bottom: 1rem;
    color: var(--brand-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Quick Action Workspace */
.workspace-tabs .nav-link {
    border-radius: 14px !important;
    font-weight: 700;
    padding: 0.9rem 1.25rem;
    color: var(--brand-dark);
    border: none !important;
}
.workspace-tabs .nav-link.active {
    background: linear-gradient(135deg, #0d9488, #14b8a6) !important;
    color: #fff !important;
}

.big-btn {
    min-height: 64px;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 16px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0.9rem 1.5rem;
    transition: transform 0.15s, box-shadow 0.15s;
}
.big-btn:active { transform: scale(0.97); }
.btn-present {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    box-shadow: 0 6px 16px rgba(34,197,94,0.35);
}
.btn-absent {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    box-shadow: 0 6px 16px rgba(239,68,68,0.35);
}
.btn-pay {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    box-shadow: 0 6px 16px rgba(245,158,11,0.4);
}
.btn-sibling {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
}

.class-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.9rem;
    border-radius: 12px;
    background: #fff;
    border: 2px solid #99f6e4;
    color: var(--brand-dark);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    margin: 0 4px 8px 0;
}
.class-chip:hover, .class-chip.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    transform: translateY(-2px);
}

.student-card-preview {
    display: flex;
    gap: 1rem;
    align-items: center;
    background: linear-gradient(135deg, #ecfdf5, #fff);
    border: 2px solid #99f6e4;
    border-radius: 20px;
    padding: 1rem;
}
.student-avatar {
    width: 80px; height: 80px;
    border-radius: 20px;
    object-fit: cover;
    background: #ccfbf1;
    border: 3px solid #5eead4;
}
.student-avatar-lg {
    width: 110px; height: 110px;
}

.code-input, .form-control, .form-select {
    border-radius: 14px !important;
    border: 2px solid #ccfbf1 !important;
    padding: 0.75rem 1rem !important;
    font-weight: 600;
    min-height: 52px;
}
.code-input:focus, .form-control:focus, .form-select:focus {
    border-color: var(--brand) !important;
    box-shadow: 0 0 0 4px rgba(13,148,136,0.15) !important;
}

.table {
    --bs-table-bg: transparent;
}
.table thead th {
    background: #ecfdf5;
    color: var(--brand-dark);
    font-weight: 800;
    border: none;
    white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-responsive {
    border-radius: 16px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.badge { font-weight: 700; padding: 0.45em 0.7em; border-radius: 10px; }

/* Login */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        linear-gradient(135deg, rgba(13,148,136,0.92), rgba(14,116,144,0.88)),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80"><circle cx="10" cy="10" r="3" fill="rgba(255,255,255,0.08)"/></svg>');
}
.login-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 28px;
    padding: 2rem;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
    text-align: center;
}
.login-logo {
    width: 84px; height: 84px;
    margin: 0 auto 1rem;
    border-radius: 24px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    display: grid; place-items: center;
    font-size: 2.2rem;
    color: #fff;
    box-shadow: 0 10px 25px rgba(245,158,11,0.4);
    animation: bounceIn 0.6s ease;
}
.login-card h1 {
    font-weight: 800;
    color: var(--brand-dark);
    font-size: 1.6rem;
}
.login-card .owner {
    color: #64748b;
    margin-bottom: 1.5rem;
}

/* Mobile topbar */
.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: linear-gradient(90deg, #0f766e, #0d9488);
    color: #fff;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.brand-mini strong { font-size: 1rem; }

/* FAB */
.quick-fab {
    position: fixed;
    bottom: 70px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1050;
}
.fab-btn {
    width: 56px; height: 56px;
    border-radius: 18px;
    display: grid; place-items: center;
    color: #fff;
    font-size: 1.4rem;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}
.fab-attend { background: linear-gradient(135deg, #22c55e, #16a34a); }
.fab-pay { background: linear-gradient(135deg, #f59e0b, #d97706); }

.app-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(8px);
    border-top: 1px solid #ccfbf1;
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    z-index: 1020;
    margin-right: 0;
}
@media (min-width: 992px) {
    .app-footer { margin-right: var(--sidebar-w); }
}

/* Sibling checklist */
.sibling-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.85rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
}
.sibling-item:hover, .sibling-item.selected {
    border-color: #3b82f6;
    background: #eff6ff;
}
.sibling-item input { width: 22px; height: 22px; }

/* Empty / Loading */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: #94a3b8;
}
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border-radius: 12px;
    height: 20px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes bounceIn {
    0% { transform: scale(0.6); opacity: 0; }
    60% { transform: scale(1.08); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeUp 0.4s ease both; }

/* Print */
@media print {
    .sidebar, .mobile-topbar, .quick-fab, .app-footer, .no-print { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    body { background: #fff; padding: 0; }
    .panel { box-shadow: none; border: 1px solid #ddd; }
}

/* Responsive - MOBILE FIRST FIX
   Root cause of half-screen teal: app-wrapper stayed display:flex on phones,
   so .mobile-topbar (teal) stretched as a full-height column beside content. */
@media (max-width: 991.98px) {
    html, body {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    .app-wrapper {
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
        max-width: 100vw !important;
        min-height: 100vh;
    }

    /* Top bar = full width row only (never a side column) */
    .mobile-topbar {
        display: flex !important;
        flex: 0 0 auto !important;
        width: 100% !important;
        max-width: 100vw !important;
        height: auto !important;
        align-self: stretch !important;
        position: sticky !important;
        top: 0;
        z-index: 1030;
        box-sizing: border-box !important;
    }

    /* Sidebar = drawer over content; hidden until .show */
    .sidebar.offcanvas-lg,
    aside.sidebar {
        width: min(86vw, 320px) !important;
        max-width: 320px !important;
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        right: 0 !important;
        left: auto !important;
        z-index: 1045 !important;
        visibility: hidden !important;
        transform: translateX(110%) !important;
        transition: transform 0.3s ease, visibility 0.3s;
        margin: 0 !important;
        flex: none !important;
        align-self: auto !important;
    }
    .sidebar.offcanvas-lg.show,
    aside.sidebar.show {
        visibility: visible !important;
        transform: none !important;
    }

    .main-content {
        display: block !important;
        flex: 1 1 auto !important;
        margin: 0 !important;
        margin-right: 0 !important;
        margin-left: 0 !important;
        padding: 12px !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    .app-footer {
        margin-right: 0 !important;
    }

    .stat-card .value { font-size: 1.5rem; }
    .big-btn {
        width: 100%;
        min-height: 58px;
        font-size: 1.1rem;
    }
    .student-card-preview {
        flex-direction: column;
        text-align: center;
    }
    .code-input { font-size: 1.2rem !important; text-align: center; letter-spacing: 2px; }
    .table { font-size: 0.85rem; }
    body { padding-bottom: 100px; }

    .offcanvas-backdrop {
        z-index: 1040;
    }
}

@media (min-width: 992px) {
    .offcanvas-lg {
        position: fixed !important;
        visibility: visible !important;
        transform: none !important;
        display: flex !important;
    }
    .offcanvas-lg .btn-close { display: none; }
}

/* Touch friendly */
button, .btn, a.nav-item, .class-chip, .sibling-item {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Charts container */
.chart-box {
    position: relative;
    height: 260px;
}

/* Status dots */
.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
}
.dot-paid { background: #22c55e; }
.dot-partial { background: #f59e0b; }
.dot-unpaid { background: #ef4444; }
