/* TradeVerify — Orange accent brand */
:root {
    --orange: #E87B35;
    --orange-dark: #D06A28;
    --orange-light: #FFF3EC;
    --green: #639922;
    --amber: #EF9F27;
    --red: #E24B4A;
    --gray: #888780;
    --blue: #378ADD;
    --bg: #F8F8F6;
    --white: #FFFFFF;
    --dark: #1A1A1A;
    --text: #333333;
    --text-light: #666666;
    --border: #E0DDD8;
    --sidebar-bg: #1E1E1E;
    --sidebar-text: #CCCCCC;
    --sidebar-active: #E87B35;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--orange); text-decoration: none; }
a:hover { color: var(--orange-dark); }

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--orange);
    letter-spacing: -0.3px;
}

.sidebar-brand .logo-icon {
    width: 28px;
    height: 28px;
    background: var(--orange);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.sidebar-section {
    padding: 16px 0 4px 0;
}

.sidebar-section-label {
    padding: 0 20px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #666;
    font-weight: 600;
    margin-bottom: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    color: var(--sidebar-text);
    font-size: 14px;
    transition: all 0.15s;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.sidebar-nav a.active {
    background: rgba(232, 123, 53, 0.15);
    color: var(--sidebar-active);
    border-right: 3px solid var(--sidebar-active);
}

.sidebar-nav .coming-soon {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.sidebar-nav .coming-soon::after {
    content: 'Soon';
    font-size: 9px;
    background: #444;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: auto;
}

.sidebar-user {
    padding: 12px 20px;
    border-top: 1px solid #333;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--sidebar-bg);
}

.sidebar-user .user-name {
    font-size: 13px;
    color: #ddd;
    font-weight: 500;
}

.sidebar-user .user-role {
    font-size: 11px;
    color: #888;
    text-transform: capitalize;
}

.sidebar-user .logout-link {
    font-size: 12px;
    color: #888;
    float: right;
    margin-top: -24px;
}

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px 32px;
    min-height: 100vh;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 16px;
}

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 20px;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover { background: var(--orange-light); }
tr:hover td { border-color: transparent; }

/* Status dots */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
}

.status-dot.current { background: var(--green); }
.status-dot.expiring_soon { background: var(--amber); }
.status-dot.expired { background: var(--red); }
.status-dot.missing { background: var(--gray); }
.status-dot.pending_proof, .status-dot.pending_review { background: var(--blue); }

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-current { background: #E8F5E0; color: var(--green); }
.badge-expiring_soon { background: #FFF4E0; color: #C47F1A; }
.badge-expired { background: #FFE8E7; color: var(--red); }
.badge-missing { background: #F0EFED; color: var(--gray); }
.badge-pending_proof, .badge-pending_review { background: #E3F0FC; color: var(--blue); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--orange);
    color: white;
}
.btn-primary:hover {
    background: var(--orange-dark);
    color: white;
}

.btn-secondary {
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-danger {
    background: var(--red);
    color: white;
}
.btn-danger:hover {
    background: #C43A3A;
    color: white;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--white);
    color: var(--text);
    transition: border 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(232, 123, 53, 0.1);
}

select.form-control {
    appearance: auto;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-inline {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
}

/* Alerts / Flash */
.flash-messages {
    margin-bottom: 16px;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 8px;
}

.alert-success { background: #E8F5E0; color: #2D6A0F; border: 1px solid #C5E1B0; }
.alert-error { background: #FFE8E7; color: #B91C1C; border: 1px solid #FCA5A5; }
.alert-warning { background: #FFF4E0; color: #92400E; border: 1px solid #FCD34D; }
.alert-info { background: #E3F0FC; color: #1E40AF; border: 1px solid #93C5FD; }

/* Empty states */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 16px;
}

/* Cert matrix */
.matrix-table th, .matrix-table td {
    text-align: center;
    padding: 8px;
    min-width: 40px;
}

.matrix-table th:first-child, .matrix-table td:first-child {
    text-align: left;
    min-width: 160px;
    position: sticky;
    left: 0;
    background: var(--white);
    z-index: 1;
}

.matrix-table th {
    font-size: 10px;
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    max-width: 40px;
    height: 120px;
    white-space: nowrap;
}

.matrix-table th:first-child {
    writing-mode: horizontal-tb;
    transform: none;
    height: auto;
}

.matrix-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

/* Crew cards */
.crew-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    overflow: hidden;
}

.crew-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.crew-header:hover { background: var(--orange-light); }

.crew-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.crew-body {
    padding: 0 20px 16px;
}

/* QR / Verification public page */
.verify-page {
    max-width: 480px;
    margin: 0 auto;
    padding: 24px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.verify-header {
    text-align: center;
    padding: 24px 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.verify-header .company-name {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.verify-header .employee-name {
    font-size: 24px;
    font-weight: 700;
}

.verify-status-bar {
    text-align: center;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 24px;
}

.verify-cert-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.verify-cert-name {
    font-weight: 500;
    font-size: 14px;
}

.verify-cert-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.verify-footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-light);
    font-size: 12px;
}

.verify-footer .powered-by {
    color: var(--orange);
    font-weight: 600;
}

/* Employee detail */
.detail-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
}

.info-card dt {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 12px;
}

.info-card dd {
    font-size: 14px;
    margin-top: 2px;
}

.action-rail {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* QR code display */
.qr-container {
    text-align: center;
    padding: 20px;
}

.qr-container img {
    max-width: 200px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Onboarding */
.onboarding-container {
    max-width: 640px;
    margin: 40px auto;
    padding: 0 20px;
}

.onboarding-progress {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
}

.onboarding-progress .step {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
}

.onboarding-progress .step.active {
    background: var(--orange);
}

.onboarding-progress .step.done {
    background: var(--green);
}

.onboarding-container h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.onboarding-container .subtitle {
    color: var(--text-light);
    margin-bottom: 24px;
}

/* Auth pages */
.auth-container {
    max-width: 420px;
    margin: 80px auto;
    padding: 0 20px;
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    border: 1px solid var(--border);
}

.auth-brand {
    text-align: center;
    margin-bottom: 24px;
}

.auth-brand h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--orange);
}

.auth-brand p {
    color: var(--text-light);
    font-size: 14px;
    margin-top: 4px;
}

/* Checkbox toggle */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 12px;
    transition: 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

input:checked + .toggle-slider { background: var(--orange); }
input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
}

.pagination a { background: var(--white); border: 1px solid var(--border); color: var(--text); }
.pagination a:hover { background: var(--orange-light); }
.pagination span.current { background: var(--orange); color: white; }

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar .search-input {
    flex: 1;
    min-width: 200px;
}

/* Diagnostics */
.diagnostics {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 2px solid var(--border);
}

.diagnostics h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin-bottom: 16px;
}

.diagnostics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.diag-item {
    padding: 12px;
    background: var(--bg);
    border-radius: 6px;
}

.diag-item .diag-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
}

.diag-item .diag-value {
    font-size: 18px;
    font-weight: 600;
    margin-top: 2px;
}

/* Document viewer */
.doc-viewer {
    background: var(--dark);
    min-height: 600px;
    border-radius: var(--radius);
    overflow: hidden;
}

.doc-viewer iframe, .doc-viewer img {
    width: 100%;
    min-height: 600px;
    border: none;
}

.doc-viewer img {
    object-fit: contain;
    min-height: auto;
    max-height: 80vh;
}

/* Not found page */
.not-found-page {
    max-width: 480px;
    margin: 80px auto;
    text-align: center;
    padding: 48px 24px;
}

.not-found-page .nf-icon {
    width: 80px;
    height: 80px;
    background: var(--red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    color: white;
    font-size: 36px;
    font-weight: 700;
}

/* Mobile hamburger */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--sidebar-bg);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
}

/* Two-column grid */
.two-col-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Responsive */
@media (max-width: 768px) {
    .mobile-toggle { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s;
    }
    .sidebar.open { transform: translateX(0); }

    .main-content {
        margin-left: 0;
        padding: 64px 16px 24px;
    }

    .stat-grid { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .two-col-grid { grid-template-columns: 1fr; }

    .page-header { flex-direction: column; align-items: flex-start; }

    .matrix-table th { height: 80px; font-size: 9px; }

    table { font-size: 13px; }
    th, td { padding: 8px; }

    /* Increase tap targets on mobile */
    .btn { padding: 10px 18px; }
    .btn-sm { padding: 8px 14px; font-size: 13px; }
    .sidebar-nav a { padding: 12px 20px; }

    /* Verify page readability */
    .verify-cert-name { font-size: 16px; }
    .verify-cert-status { font-size: 15px; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .auth-container { margin: 40px auto; }
}

/* Print QR */
@media print {
    .sidebar, .mobile-toggle, .action-rail, .page-header .btn { display: none !important; }
    .main-content { margin-left: 0; }
    .qr-container img { max-width: 300px; }
}
