/* =============================================
   AI Staff University - Master CSS
   Mobile-First | Glassmorphism | Dark Mode
   ============================================= */

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0D1117;
    color: #E6EDF3;
    min-height: 100vh;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
a { color: #6C5CE7; text-decoration: none; }
img { max-width: 100%; height: auto; }

/* === CSS Variables === */
:root {
    --primary: #6C5CE7;
    --primary-light: #a855f7;
    --secondary: #00CEC9;
    --accent: #FD79A8;
    --success: #00B894;
    --warning: #FDCB6E;
    --danger: #FF6B6B;
    --bg: #0D1117;
    --surface: #161B22;
    --surface-glass: rgba(255,255,255,0.05);
    --text: #E6EDF3;
    --text-secondary: #8B949E;
    --border: rgba(255,255,255,0.1);
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* === Top Navigation === */
.top-nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: 56px;
    padding: calc(0px + env(safe-area-inset-top, 0px)) 16px 0;
    background: rgba(13,17,23,0.95);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.nav-left, .nav-right { display: flex; align-items: center; gap: 12px; }
.hamburger-btn { background: none; border: none; color: var(--text); cursor: pointer; padding: 8px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--text); }
.logo-icon { font-size: 24px; }
.logo-text { display: none; }
.credit-badge {
    display: flex; align-items: center; gap: 6px;
    background: var(--surface-glass); border: 1px solid var(--border);
    padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 600;
    color: var(--success);
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: white;
}

/* === Sidebar (Desktop) === */
.sidebar {
    display: none; position: fixed; top: 56px; left: 0; bottom: 0;
    width: 260px; background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto; z-index: 50;
    flex-direction: column;
}
.sidebar-brand { padding: 20px; font-weight: 700; font-size: 14px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.sidebar-nav { flex: 1; padding: 8px; }
.sidebar-footer { padding: 8px; border-top: 1px solid var(--border); }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 14px; font-weight: 500;
    transition: all 0.2s; margin-bottom: 2px;
}
.nav-item:hover, .nav-item.active { background: var(--surface-glass); color: var(--text); }
.nav-item.active { background: rgba(108,92,231,0.15); color: var(--primary); }
.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }
.nav-item.logout { color: var(--danger); }

/* === Mobile Menu === */
.mobile-menu-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; opacity: 0; visibility: hidden; transition: all 0.3s; }
.mobile-menu-overlay.open { opacity: 1; visibility: visible; }
.mobile-menu-panel {
    position: fixed; top: 0; left: 0; width: 280px; height: 100%;
    background: var(--surface); transform: translateX(-100%);
    transition: transform 0.3s ease; z-index: 201;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.mobile-menu-overlay.open .mobile-menu-panel { transform: translateX(0); }
.menu-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border); }
.menu-header h3 { font-size: 16px; }
.close-menu { background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; padding: 8px; }
.mobile-menu-item {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px; min-height: 48px;
    color: var(--text); border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 15px;
}
.mobile-menu-item.active { color: var(--primary); background: rgba(108,92,231,0.1); }
.mobile-menu-item.logout { color: var(--danger); }

/* === Bottom Tab Bar === */
.bottom-tab-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(13,17,23,0.95);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-around; align-items: center;
    z-index: 100;
}
.tab-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 10px; color: var(--text-secondary);
    -webkit-tap-highlight-color: transparent;
    background: none; border: none; cursor: pointer;
    padding: 8px 4px; min-width: 56px;
}
.tab-item.active { color: var(--primary); }
.tab-icon { font-size: 20px; }

/* === Main Content === */
.main-content {
    padding: calc(56px + env(safe-area-inset-top, 0px) + 16px) 16px 16px;
    min-height: 100vh;
}

/* === Cards === */
.card {
    background: var(--surface-glass);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 12px;
}
@media (hover: hover) { .card:hover { transform: translateY(-2px); box-shadow: var(--shadow); } }
.card:active { transform: scale(0.98); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-title { font-size: 16px; font-weight: 600; }

/* === Stats Grid === */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; text-align: center;
}
.stat-value { font-size: 28px; font-weight: 700; background: linear-gradient(135deg, var(--primary), var(--secondary)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 12px 24px;
    border: none; border-radius: var(--radius-sm);
    font-size: 16px; font-weight: 600; font-family: inherit;
    cursor: pointer; transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; }
.btn-success { background: linear-gradient(135deg, var(--success), #55efc4); color: white; }
.btn-danger { background: linear-gradient(135deg, var(--danger), #ee5a24); color: white; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { min-height: 36px; padding: 8px 16px; font-size: 13px; width: auto; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px; display: flex; align-items: center; justify-content: center; transition: transform 0.1s; }
.btn-icon:active { transform: scale(0.9); }
.btn:active { transform: scale(0.95); }

/* === Form Elements === */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 14px 16px;
    background: var(--surface-glass); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text); font-size: 16px; font-family: inherit;
    transition: border-color 0.2s;
    -webkit-appearance: none; appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.2);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238B949E' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px; }
.form-select option {
    background-color: var(--surface);
    color: var(--text);
}

/* === Badges === */
.badge {
    display: inline-flex; align-items: center; padding: 4px 10px;
    border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-training { background: var(--warning); color: #000; }
.badge-graduated { background: var(--secondary); color: #000; }
.badge-active { background: var(--success); color: #fff; }
.badge-sos { background: var(--danger); color: #fff; animation: pulse 1s infinite; }
.badge-suspended { background: var(--text-secondary); color: #fff; }

/* === Tables (Desktop) === */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-secondary); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:hover { background: var(--surface-glass); }

/* === Staff Card List (Mobile) === */
.staff-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.staff-avatar-sm { width: 48px; height: 48px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.staff-info { flex: 1; }
.staff-name { font-weight: 600; font-size: 15px; }
.staff-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* === Operation Room === */
.operation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.op-staff-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; text-align: center;
    position: relative; overflow: hidden;
}
.op-staff-card.sos { border-color: var(--danger); animation: sosPulse 2s infinite; }
.op-emoji { font-size: 32px; margin-bottom: 4px; }
.op-avatar { font-size: 48px; margin-bottom: 8px; animation: idleBounce 3s ease-in-out infinite; }
.op-staff-card.sos .op-avatar { animation: sosShake 0.5s infinite; }
.op-name { font-weight: 600; font-size: 14px; }
.op-workload { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.op-pile { display: flex; justify-content: center; gap: 2px; margin-top: 8px; }
.op-pile-doc { width: 16px; height: 20px; background: var(--warning); border-radius: 2px; opacity: 0.7; }

/* Whisper Bar */
.whisper-bar {
    position: fixed; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); left: 0; right: 0;
    padding: 8px 16px; background: rgba(22,27,34,0.95);
    backdrop-filter: blur(10px); display: flex; gap: 8px; z-index: 90;
    border-top: 1px solid var(--border);
}
.whisper-bar .form-input { font-size: 14px; padding: 10px 12px; }
.whisper-bar .btn { width: auto; min-height: 40px; padding: 8px 16px; }

/* === Page Header === */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* === Alerts === */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    font-size: 14px; margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}
.alert-success { background: rgba(0,184,148,0.15); border: 1px solid var(--success); color: var(--success); }
.alert-error { background: rgba(255,107,107,0.15); border: 1px solid var(--danger); color: var(--danger); }
.alert-warning { background: rgba(253,203,110,0.15); border: 1px solid var(--warning); color: var(--warning); }

/* === Empty State === */
.empty-state { text-align: center; padding: 48px 16px; color: var(--text-secondary); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }

/* === Animations === */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes idleBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes sosPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,107,0.4); } 50% { box-shadow: 0 0 20px 4px rgba(255,107,107,0.2); } }
@keyframes sosShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: calc(200px + 100%) 0; } }

.fade-in { animation: fadeIn 0.3s ease; }

/* === Responsive === */
@media (min-width: 768px) {
    body { padding-bottom: 0; }
    .bottom-tab-bar { display: none; }
    .hamburger-btn { display: none; }
    .logo-text { display: inline; }
    .sidebar { display: flex; flex-direction: column; }
    .main-content { margin-left: 260px; padding: 80px 24px 24px; }
    .btn { width: auto; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .operation-grid { grid-template-columns: repeat(3, 1fr); }
    .whisper-bar { left: 260px; bottom: 0; }
}
@media (min-width: 1200px) {
    .operation-grid { grid-template-columns: repeat(4, 1fr); }
    .main-content { padding: 80px 32px 32px; }
}
@media (min-width: 1440px) {
    .main-content { max-width: 1200px; }
}
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* === Auth Pages === */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 24px; }
.auth-card h1 { text-align: center; font-size: 24px; margin-bottom: 8px; }
.auth-card .subtitle { text-align: center; color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.auth-card .logo-large { text-align: center; font-size: 48px; margin-bottom: 16px; }
.auth-links { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-secondary); }
