@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.1);
    --secondary-color: #06b6d4;
    --secondary-hover: #0891b2;
    --success-color: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning-color: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger-color: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-border: rgba(255, 255, 255, 0.1);
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --font-thai: 'Kanit', sans-serif;
    --font-eng: 'Outfit', sans-serif;
}

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

body {
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
    color: var(--text-main);
    font-family: var(--font-thai);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header & Switcher Styles */
header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.simulation-selector {
    display: flex;
    gap: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    padding: 0.25rem;
    border-radius: 9999px;
    border: 1px solid var(--card-border);
}

.sim-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    cursor: pointer;
    font-family: var(--font-thai);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sim-btn.active {
    background: var(--primary-color);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.sim-btn:hover:not(.active) {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* Container & Main Layout */
.container {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Container */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow-premium);
    width: 100%;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

/* View Sections visibility */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Login Panel Styling */
.login-card {
    max-width: 480px;
    margin: 4rem auto;
    text-align: center;
}

.login-icon {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.role-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 2rem 0;
}

.role-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.role-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    background: rgba(99, 102, 241, 0.05);
}

.role-card.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.role-card i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
    color: var(--text-muted);
}

.role-card.selected i {
    color: var(--primary-color);
}

.role-card span {
    font-weight: 500;
    font-size: 1.1rem;
    display: block;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.input-control {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: var(--font-thai);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.25);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--primary-color);
    color: var(--text-main);
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-thai);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-success {
    background: var(--success-color);
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger-color);
}

.btn-danger:hover {
    background: #dc2626;
}

.error-message {
    color: var(--danger-color);
    background: var(--danger-bg);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-top: 1rem;
    display: none;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Dashboard Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 350px 1fr;
    }
}

/* Profile Card */
.profile-card {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--card-border);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 1rem;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.profile-name {
    font-size: 1.15rem;
    font-weight: 600;
}

.profile-class {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.profile-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-weight: 500;
    font-size: 0.95rem;
}

.allergy-badge {
    background: var(--danger-bg);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.5rem;
    border-radius: 8px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.disease-badge {
    background: var(--warning-bg);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
    padding: 0.5rem;
    border-radius: 8px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Symptoms Form and Requests */
.form-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.symptoms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.symptom-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.symptom-card:hover {
    border-color: var(--secondary-color);
    background: rgba(6, 182, 212, 0.05);
}

.symptom-card.selected {
    border-color: var(--secondary-color);
    background: linear-gradient(135deg, var(--secondary-color), #0891b2);
    color: #0f172a;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
    transform: translateY(-2px);
}

.symptom-card i {
    font-size: 1.5rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: block;
    transition: color 0.2s ease;
}

.symptom-card.selected i {
    color: #0f172a;
}

/* Student Requests Queue on Student Dashboard */
.req-status-panel {
    margin-top: 1.5rem;
    border-top: 1px solid var(--card-border);
    padding-top: 1.5rem;
}

.status-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--warning-color);
}

.status-card.approved {
    border-left-color: var(--success-color);
}

.status-card.rejected {
    border-left-color: var(--danger-color);
}

.status-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.status-title {
    font-weight: 500;
}

.status-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-badge.pending {
    background: var(--warning-bg);
    color: var(--warning-color);
}

.status-badge.approved {
    background: var(--success-bg);
    color: var(--success-color);
}

.status-badge.rejected {
    background: var(--danger-bg);
    color: var(--danger-color);
}

/* Teacher Dashboard Layout */
.teacher-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .teacher-layout {
        grid-template-columns: 240px 1fr;
    }
}

.teacher-sidebar {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 16px;
    border: 1px solid var(--card-border);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: fit-content;
}

.sidebar-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    text-align: left;
    font-family: var(--font-thai);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.sidebar-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-btn.active {
    background: var(--primary-light);
    color: var(--primary-color);
}

.sidebar-btn .badge {
    margin-left: auto;
    background: var(--danger-color);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.teacher-content {
    min-height: 400px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Requests Cards - Teacher View */
.requests-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.request-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    position: relative;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.request-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
}

@media (min-width: 768px) {
    .request-card {
        grid-template-columns: auto 1fr auto;
        align-items: center;
    }
}

.request-user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--secondary-color);
}

.request-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.request-meta {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.request-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.req-badge-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.request-symptoms {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--secondary-color);
    margin-top: 0.5rem;
}

.request-actions {
    display: flex;
    gap: 0.75rem;
}

@media (max-width: 767px) {
    .request-actions {
        width: 100%;
    }
    .request-actions .btn {
        flex: 1;
    }
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: #1e293b;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-box {
    transform: translateY(0);
}

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

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-main);
}

/* Table Style */
.table-responsive {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--card-border);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

th, td {
    padding: 1rem;
    border-bottom: 1px solid var(--card-border);
}

th {
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Cabinet/Medicine Slots Grid */
.cabinet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.cabinet-slot {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--danger-color); /* Red default border for locked */
    border-radius: 14px;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.cabinet-slot::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--danger-color); /* Red indicator for locked */
}

.cabinet-slot.unlocked {
    border-color: var(--success-color);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
    animation: pulseBorder 1.5s infinite;
}

.cabinet-slot.unlocked::before {
    background: var(--success-color);
    animation: flashGreenTop 1.5s infinite;
}

@keyframes pulseBorder {
    0%, 100% { border-color: var(--success-color); }
    50% { border-color: rgba(16, 185, 129, 0.3); }
}

@keyframes flashGreenTop {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.slot-number {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.slot-med-name {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.slot-qty {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin: 0.5rem 0;
}

.slot-qty span {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

.slot-status {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 500;
}

.slot-status.locked {
    color: var(--danger-color);
}

.slot-status.active-unlocked {
    color: var(--success-color);
    animation: flashText 1s infinite;
}

@keyframes flashText {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Cabinet slot configuration overlay */
.slot-action-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.slot-action-btn:hover {
    color: var(--text-main);
}

/* Empty State Styling */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--card-border);
}

/* Live Announcement Box for cabinet activity */
.announcement-banner {
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success-color);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    display: none;
    align-items: center;
    gap: 0.75rem;
    animation: slideDown 0.3s ease forwards;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.announcement-banner.active {
    display: flex;
}

.announcement-icon {
    font-size: 1.5rem;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Quick Search bar for Student Database */
.table-header-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .table-header-actions {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.search-input-wrapper {
    position: relative;
    max-width: 320px;
    width: 100%;
}

.search-input-wrapper i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input-wrapper input {
    padding-left: 2.25rem;
}

/* Floating Notification toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 2000;
}

.toast {
    background: #1e293b;
    border: 1px solid var(--card-border);
    border-left: 4px solid var(--primary-color);
    border-radius: 8px;
    padding: 1rem;
    min-width: 300px;
    max-width: 450px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}
