/* ==========================================================================
   7090324 - THIẾT KẾ MẠCH IN | MODERN PCB DESIGN & IPC AI GRADER UI
   Đồng bộ phong cách trực quan sáng rõ của hệ thống thực hành FPGA HUMG
   ========================================================================== */

:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #ffffff;
    --border-color: #e2e8f0;
    --border-active: #2563eb;

    --text-main: #0f172a;
    --text-muted: #475569;
    --text-subtle: #64748b;

    --accent-blue: #2563eb;
    --accent-cyan: #0d9488;
    --accent-green: #059669;
    --accent-amber: #d97706;
    --accent-red: #dc2626;
    --accent-purple: #7c3aed;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 30px -4px rgba(37, 99, 235, 0.12), 0 4px 10px -2px rgba(15, 23, 42, 0.04);

    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 6px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    background-image:
        radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.07) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(13, 148, 136, 0.06) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(245, 158, 11, 0.04) 0px, transparent 50%);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 1rem;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.28);
    text-align: center;
    max-height: 92vh;
    overflow-y: auto;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.modal-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

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

.form-group label {
    display: block;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.7rem 0.95rem;
    background: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.92rem;
    transition: all 0.2s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.form-control-locked {
    background: #eff6ff !important;
    border-color: #93c5fd !important;
    color: #1e3a8a !important;
    font-weight: 700 !important;
    cursor: not-allowed;
}

.btn-primary {
    padding: 0.7rem 1.2rem;
    background: linear-gradient(135deg, #2563eb, #0284c7);
    border: none;
    border-radius: var(--radius-md);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1.5px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.38);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 0.55rem 0.95rem;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.18s;
}

.btn-secondary:hover {
    border-color: var(--accent-blue);
    background: #eff6ff;
    color: var(--accent-blue);
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.7rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #059669, #0284c7);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.brand-title h1 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-main);
}

.brand-title p {
    font-size: 0.76rem;
    color: var(--text-subtle);
}

.nav-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.nav-tab {
    padding: 0.5rem 0.95rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.84rem;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-tab:hover {
    background: var(--bg-card-hover);
    color: var(--text-main);
}

.nav-tab.active {
    background: #eff6ff;
    color: var(--accent-blue);
    border-color: #bfdbfe;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 4px 10px 4px 5px;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #0d9488);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.74rem;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-details strong {
    font-size: 0.8rem;
    color: var(--text-main);
}

.user-details span {
    font-size: 0.7rem;
    color: var(--text-subtle);
}

.btn-logout {
    border: none;
    background: #fee2e2;
    color: #b91c1c;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
}

.badge-easy { background: #dcfce7; color: #166534; }
.badge-medium { background: #fef3c7; color: #92400e; }
.badge-hard { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }

/* Main Container */
.main-container {
    width: 100%;
    max-width: 1520px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem 3rem;
    flex: 1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Workspace Layout */
.pcb-workspace-grid {
    display: grid;
    grid-template-columns: 270px 1fr;
    gap: 1.25rem;
    align-items: start;
}

.ws-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 84px;
}

.ws-sidebar-header {
    padding: 0.9rem 1rem;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.86rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ws-lab-list {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ws-lab-item {
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: #ffffff;
    cursor: pointer;
    transition: all 0.18s;
}

.ws-lab-item:hover {
    border-color: #93c5fd;
    background: #f8fafc;
}

.ws-lab-item.active {
    border-color: var(--accent-blue);
    background: #eff6ff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

.ws-lab-item-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-main);
}

.ws-lab-item-sub {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
    color: var(--text-subtle);
    margin-top: 4px;
}

/* Exam Spec Card */
.card-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
}

.exam-spec-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 1.25rem;
    align-items: start;
    margin-top: 1rem;
}

.schematic-preview-box {
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    text-align: center;
}

.schematic-preview-box img {
    max-width: 100%;
    max-height: 330px;
    object-fit: contain;
    cursor: zoom-in;
    border-radius: 6px;
}

.constraint-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    font-size: 0.84rem;
}

.constraint-box ul {
    padding-left: 1.15rem;
    margin-top: 0.45rem;
    color: var(--text-muted);
}

.constraint-box li {
    margin-bottom: 0.35rem;
}

/* 5-Slot Upload Grid */
.upload-slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.upload-slot-card {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    background: #f8fafc;
    padding: 1rem;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.upload-slot-card:hover,
.upload-slot-card.drag-over {
    border-color: var(--accent-blue);
    background: #eff6ff;
}

.upload-slot-card.has-file {
    border-style: solid;
    border-color: var(--accent-green);
    background: #f0fdf4;
}

.slot-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.slot-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: var(--accent-blue);
    color: #fff;
    font-size: 0.76rem;
    font-weight: 800;
    flex-shrink: 0;
}

.upload-slot-card.has-file .slot-number {
    background: var(--accent-green);
}

.slot-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
}

.slot-accept {
    font-size: 0.74rem;
    color: var(--text-subtle);
    margin-bottom: 0.65rem;
}

.slot-drop-area {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.slot-drop-area:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.slot-file-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.78rem;
}

.slot-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border: 1px solid #bbf7d0;
    padding: 4px 8px;
    border-radius: 6px;
}

.slot-thumb-grid {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.slot-thumb-grid img {
    width: 72px;
    height: 54px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    cursor: zoom-in;
}

/* AI Grade Card */
.grade-result-card {
    background: #ffffff;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-top: 1.25rem;
    box-shadow: var(--shadow-md);
}

.grade-result-card.pass {
    border-color: #10b981;
}

.grade-result-card.fail {
    border-color: #f59e0b;
}

.grade-score-circle {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.grade-checks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.grade-check-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    background: #f8fafc;
    font-size: 0.82rem;
}

.grade-check-item.ok {
    border-left: 4px solid #059669;
    background: #f0fdf4;
}

.grade-check-item.warn {
    border-left: 4px solid #dc2626;
    background: #fef2f2;
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.data-table th, .data-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.data-table th {
    background: #f1f5f9;
    font-weight: 700;
    color: var(--text-main);
}

.data-table tr:hover td {
    background: #f8fafc;
}

/* IPC Reference Grid */
.ipc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1rem;
}

.ipc-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    box-shadow: var(--shadow-sm);
}

.ipc-card h3 {
    color: var(--accent-blue);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.ipc-card ul {
    padding-left: 1.15rem;
    font-size: 0.84rem;
    color: var(--text-muted);
}

.ipc-card li {
    margin-bottom: 0.4rem;
}

/* Print / PDF styles */
.print-only {
    display: none;
}

@media print {
    .no-print { display: none !important; }
    .print-only { display: block !important; }
    body { background: #ffffff !important; }
    .report-page {
        padding: 12mm;
        font-family: "Times New Roman", Inter, serif;
        color: #000;
    }
    .report-header {
        text-align: center;
        border-bottom: 2px solid #1e3a8a;
        padding-bottom: 8px;
        margin-bottom: 12px;
    }
    .report-info-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px 16px;
        font-size: 10pt;
        margin-bottom: 12px;
        background: #f8fafc;
        padding: 8px 10px;
        border: 1px solid #cbd5e1;
    }
}

@media (max-width: 980px) {
    .pcb-workspace-grid {
        grid-template-columns: 1fr;
    }
    .ws-sidebar {
        position: static;
    }
    .exam-spec-grid {
        grid-template-columns: 1fr;
    }
}
