/* ============================================================
   Lesson Plan Management System (ระบบจัดส่งและประเมินแผนการจัดการเรียนรู้)
   Theme: Emerald Green & White (โทนสีเขียวมรกต - ขาว สง่างาม ทันสมัย)
   ============================================================ */

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

:root {
    /* Emerald Green Master Palette */
    --primary-green: #059669;
    --primary-green-hover: #047857;
    --dark-green: #065f46;
    --deep-forest: #022c22;
    --light-green-bg: #ecfdf5;
    --green-border: #a7f3d0;
    --mint-soft: #d1fae5;
    --emerald-accent: #10b981;
    --lime-accent: #84cc16;

    /* Aliasing red variables to green for instant complete theme transformation */
    --primary-red: #059669;
    --primary-red-hover: #047857;
    --dark-red: #065f46;
    --deep-burgundy: #022c22;
    --light-red-bg: #ecfdf5;
    --rose-border: #a7f3d0;
    --pink-soft: #d1fae5;
    
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    /* Status Colors */
    --status-pending-dept-bg: #fffbebf8;
    --status-pending-dept-text: #b45309;
    --status-pending-dept-border: #fde68a;
    
    --status-pending-admin-bg: #eff6ff;
    --status-pending-admin-text: #1d4ed8;
    --status-pending-admin-border: #bfdbfe;
    
    --status-approved-bg: #ecfdf5;
    --status-approved-text: #059669;
    --status-approved-border: #a7f3d0;
    
    --status-rejected-bg: #fef2f2;
    --status-rejected-text: #dc2626;
    --status-rejected-border: #fecaca;

    --sidebar-width: 275px;
    --topbar-height: 70px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(5, 150, 105, 0.10);
    --shadow-lg: 0 10px 25px rgba(5, 150, 105, 0.14);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #064e3b 0%, #059669 50%, #022c22 100%);
    color: #ffffff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0,0,0,0.18);
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}

.sidebar-brand-icon {
    width: 44px;
    height: 44px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.22));
}

.sidebar-brand-text h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #ffffff;
    line-height: 1.25;
}

.sidebar-brand-text span {
    font-size: 0.74rem;
    color: #a7f3d0;
    font-weight: 400;
}

.sidebar-nav {
    padding: 18px 12px;
    flex: 1;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6ee7b7;
    padding: 10px 16px 6px;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: #ecfdf5;
    text-decoration: none;
    font-size: 0.93rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin-bottom: 5px;
    transition: all 0.2s ease;
}

.nav-link i {
    font-size: 1.05rem;
    width: 22px;
    text-align: center;
    opacity: 0.9;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    transform: translateX(3px);
}

.nav-link.active {
    background: #ffffff;
    color: var(--primary-green);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.nav-link.active i {
    color: var(--primary-green);
    opacity: 1;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.15);
}

.user-profile-mini {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ffffff;
    color: var(--primary-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    border: 2px solid #a7f3d0;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #ffffff;
}

.user-role-badge {
    display: inline-block;
    font-size: 0.72rem;
    background: rgba(255,255,255,0.22);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 400;
}

/* Main Content Area */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

body.sidebar-hidden .sidebar {
    transform: translateX(-100%);
}

body.sidebar-hidden .main-wrapper {
    margin-left: 0;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    margin-right: 14px;
    transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
    background: var(--light-green-bg);
    color: var(--primary-green);
    border-color: var(--green-border);
}

/* Topbar Header */
.topbar {
    height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--dark-green);
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-demo-switch {
    font-size: 0.82rem;
    background: var(--light-green-bg);
    color: var(--primary-green);
    border: 1px solid var(--green-border);
    padding: 6px 14px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-demo-switch:hover {
    background: var(--primary-green);
    color: #ffffff;
}

/* Page Content Padding */
.content-body {
    padding: 28px 30px;
    flex: 1;
}

/* Green-White Theme Card */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
}

.card-header.bg-red-accent,
.card-header.bg-green-accent {
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border-bottom: 2px solid var(--green-border);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark-green);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 24px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background: var(--primary-green);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: var(--light-green-bg);
    color: var(--primary-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card.stat-yellow::before { background: #f59e0b; }
.stat-card.stat-yellow .stat-icon { background: #fef3c7; color: #d97706; }

.stat-card.stat-blue::before { background: #0284c7; }
.stat-card.stat-blue .stat-icon { background: #e0f2fe; color: #0284c7; }

.stat-card.stat-green::before { background: #10b981; }
.stat-card.stat-green .stat-icon { background: #d1fae5; color: #059669; }

.stat-card.stat-purple::before { background: #8b5cf6; }
.stat-card.stat-purple .stat-icon { background: #ede9fe; color: #7c3aed; }

.stat-card.stat-gray::before { background: #64748b; }
.stat-card.stat-gray .stat-icon { background: #f1f5f9; color: #475569; }

.stat-info h3 {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-main);
}

.stat-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--dark-green) 100%);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-green-hover) 0%, var(--deep-forest) 100%);
    box-shadow: 0 6px 14px rgba(5, 150, 105, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #f1f5f9;
}

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

.btn-danger {
    background: #dc2626;
    color: #ffffff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
    border-radius: 6px;
}

/* Tables & Pagination */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.custom-table th {
    background: var(--light-green-bg);
    color: var(--dark-green);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 16px;
    border-bottom: 2px solid var(--green-border);
}

.custom-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    vertical-align: middle;
}

.custom-table tbody tr {
    transition: background 0.15s;
}

.custom-table tbody tr:hover {
    background: #f0fdf4;
}

/* Pagination Styling (Max 20 Items per page) */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.pagination-info strong {
    color: var(--primary-green);
}

.pagination-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
}

.page-btn:hover:not(.disabled) {
    border-color: var(--primary-green);
    color: var(--primary-green);
    background: var(--light-green-bg);
}

.page-btn.active {
    background: var(--primary-green);
    color: #ffffff;
    border-color: var(--primary-green);
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}

.page-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f1f5f9;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
}

.badge-pending-dept {
    background: var(--status-pending-dept-bg);
    color: var(--status-pending-dept-text);
    border: 1px solid var(--status-pending-dept-border);
}

.badge-pending-admin {
    background: var(--status-pending-admin-bg);
    color: var(--status-pending-admin-text);
    border: 1px solid var(--status-pending-admin-border);
}

.badge-approved {
    background: var(--status-approved-bg);
    color: var(--status-approved-text);
    border: 1px solid var(--status-approved-border);
}

.badge-rejected {
    background: var(--status-rejected-bg);
    color: var(--status-rejected-text);
    border: 1px solid var(--status-rejected-border);
}

/* Upload Dropzone & Progress Bar Component */
.upload-dropzone {
    border: 2px dashed var(--green-border);
    background: var(--light-green-bg);
    border-radius: var(--radius-md);
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--primary-green);
    background: #d1fae5;
    transform: scale(1.01);
}

.upload-icon {
    width: 64px;
    height: 64px;
    background: #ffffff;
    color: var(--primary-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 16px;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.15);
}

.upload-text h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-green);
    margin-bottom: 6px;
}

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

.file-input-hidden {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Upload Progress Bar Container */
.upload-progress-card {
    background: #ffffff;
    border: 1px solid var(--green-border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 20px;
    box-shadow: var(--shadow-sm);
    display: none; /* hidden until upload starts */
}

.upload-file-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.file-info-text {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-info-text i {
    font-size: 1.5rem;
    color: var(--primary-green);
}

.file-name-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.file-size-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.upload-percentage-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-green);
}

.progress-track {
    width: 100%;
    height: 12px;
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #34d399 0%, #10b981 50%, #047857 100%);
    border-radius: 10px;
    transition: width 0.15s ease-out;
    box-shadow: 0 0 10px rgba(5, 150, 105, 0.4);
}

.progress-status-msg {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Form Controls */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.form-label span.required {
    color: #dc2626;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.92rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-main);
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.18);
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

/* 2-Tier Workflow Timeline */
.timeline-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    margin: 30px 0;
}

.timeline-stepper::before {
    content: '';
    position: absolute;
    top: 24px;
    left: 40px;
    right: 40px;
    height: 4px;
    background: #e2e8f0;
    z-index: 1;
}

.timeline-step {
    position: relative;
    z-index: 2;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
}

.step-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #cbd5e1;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.timeline-step.completed .step-circle {
    background: #059669;
    border-color: #059669;
    color: #ffffff;
}

.timeline-step.current .step-circle {
    background: var(--primary-green);
    border-color: #a7f3d0;
    color: #ffffff;
    box-shadow: 0 0 0 5px rgba(5, 150, 105, 0.2);
}

.timeline-step.rejected .step-circle {
    background: #dc2626;
    border-color: #fecaca;
    color: #ffffff;
}

.step-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 10px;
}

.step-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-backdrop.active {
    display: flex;
}

.modal-box {
    background: #ffffff;
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 540px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    border: 1px solid var(--green-border);
    overflow: hidden;
    animation: modalPop 0.25s ease;
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 18px 24px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border-bottom: 1px solid var(--green-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 1.15rem;
    color: var(--dark-green);
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    max-height: calc(90vh - 130px);
}

.modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Alerts & Toasts */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .topbar {
        padding: 0 16px;
    }
    .content-body {
        padding: 16px;
    }
}


/* Fix Drag and Drop pointer events */
.upload-dropzone .upload-icon,
.upload-dropzone .upload-text,
.upload-dropzone h4,
.upload-dropzone p,
.upload-dropzone i {
    pointer-events: none;
}
.upload-dropzone.has-file {
    border-style: solid;
}
