/* portal.css — Joshua Bearing Enterprise B2B Customer Portal */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Montserrat:wght@600;700;800&display=swap');

:root {
    --primary: #0f172a;
    --primary-light: #1e293b;
    --primary-accent: #2563eb;
    --primary-accent-hover: #1d4ed8;
    --brand-orange: #f97316;
    
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-subtle: #f1f5f9;
    
    --border-color: #e2e8f0;
    --border-dark: #cbd5e1;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --status-paid-bg: #ecfdf5;
    --status-paid-text: #047857;
    --status-paid-border: #a7f3d0;
    
    --status-due-bg: #fffbeb;
    --status-due-text: #b45309;
    --status-due-border: #fde68a;
    
    --status-transit-bg: #eff6ff;
    --status-transit-text: #1d4ed8;
    --status-transit-border: #bfdbfe;
    
    --status-closed-bg: #f1f5f9;
    --status-closed-text: #475569;
    --status-closed-border: #cbd5e1;
    
    --status-cancel-bg: #fef2f2;
    --status-cancel-text: #b91c1c;
    --status-cancel-border: #fecaca;
    
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ── Top Header ─────────────────────────────────────────── */
.portal-header {
    background-color: var(--primary);
    color: #ffffff;
    border-bottom: 1px solid #334155;
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.portal-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: #ffffff;
}

.brand-logo {
    height: 38px;
    width: auto;
    object-fit: contain;
}

.brand-divider {
    height: 20px;
    width: 1px;
    background-color: #334155;
}

.brand-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #f8fafc;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
}

.header-user-wrap {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.user-info {
    text-align: right;
}

.user-company {
    font-weight: 600;
    font-size: 0.88rem;
    color: #f8fafc;
}

.user-email {
    font-size: 0.75rem;
    color: #94a3b8;
}

.btn-secondary-sm {
    background-color: transparent;
    border: 1px solid #475569;
    color: #e2e8f0;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-secondary-sm:hover {
    background-color: #1e293b;
    border-color: #64748b;
    color: #ffffff;
}

/* ── Main Container ─────────────────────────────────────── */
.portal-main {
    max-width: 1280px;
    margin: 1.5rem auto 3rem;
    padding: 0 1.5rem;
}

/* ── Auth Screen ────────────────────────────────────────── */
.auth-container {
    max-width: 440px;
    margin: 4rem auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.5rem 2rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

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

.auth-form-group {
    margin-bottom: 1.25rem;
}

.auth-form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.auth-input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s ease;
}

.auth-input:focus {
    border-color: var(--primary-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-primary-block {
    width: 100%;
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    padding: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.btn-primary-block:hover {
    background-color: var(--primary-light);
}

.btn-primary-block:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
}

.auth-hint {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
}

.otp-boxes {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.otp-box {
    width: 44px;
    height: 48px;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    outline: none;
}

.otp-box:focus {
    border-color: var(--primary-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ── Dashboard KPI Cards ────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

.kpi-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.kpi-value {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
}

.kpi-value.alert {
    color: var(--status-due-text);
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* ── Table Toolbar ──────────────────────────────────────── */
.toolbar-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 0.85rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tab-group {
    display: flex;
    gap: 0.25rem;
    background-color: var(--bg-subtle);
    padding: 3px;
    border-radius: var(--radius-md);
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.tab-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-input-wrap {
    position: relative;
    width: 240px;
}

.search-input {
    width: 100%;
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    outline: none;
    font-family: inherit;
}

.search-input:focus {
    border-color: var(--primary-accent);
}

.btn-tool {
    background: #ffffff;
    border: 1px solid var(--border-dark);
    color: var(--text-main);
    padding: 0.45rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.15s ease;
}

.btn-tool:hover {
    background-color: var(--bg-subtle);
    border-color: #94a3b8;
}

/* ── Data Table ─────────────────────────────────────────── */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

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

.portal-table th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.portal-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.portal-table tbody tr:hover {
    background-color: #f8fafc;
}

.portal-table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Status Badges ──────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-paid {
    background-color: var(--status-paid-bg);
    color: var(--status-paid-text);
    border-color: var(--status-paid-border);
}

.badge-due {
    background-color: var(--status-due-bg);
    color: var(--status-due-text);
    border-color: var(--status-due-border);
}

.badge-transit {
    background-color: var(--status-transit-bg);
    color: var(--status-transit-text);
    border-color: var(--status-transit-border);
}

.badge-closed {
    background-color: var(--status-closed-bg);
    color: var(--status-closed-text);
    border-color: var(--status-closed-border);
}

.badge-cancelled {
    background-color: var(--status-cancel-bg);
    color: var(--status-cancel-text);
    border-color: var(--status-cancel-border);
}

.tracking-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--primary-accent);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.78rem;
}

.tracking-link-btn:hover {
    text-decoration: underline;
    color: var(--primary-accent-hover);
}

/* ── Modal Overlay & Dialog ─────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
    backdrop-filter: blur(2px);
}

.modal-dialog {
    background: #ffffff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.modal-header {
    background-color: var(--primary);
    color: #ffffff;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.modal-close-btn:hover {
    color: #ffffff;
}

.modal-body {
    padding: 1.5rem;
    flex: 1;
}

/* ── Shipment Timeline ──────────────────────────────────── */
.timeline-card {
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.timeline-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-top: 0.75rem;
    padding: 0 0.5rem;
}

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

.step-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #cbd5e1;
    border: 2px solid #ffffff;
    margin-bottom: 0.35rem;
}

.timeline-step.completed .step-dot {
    background-color: var(--status-paid-text);
}

.timeline-step.current .step-dot {
    background-color: var(--primary-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.step-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}

.timeline-step.completed .step-label,
.timeline-step.current .step-label {
    color: var(--primary);
    font-weight: 700;
}

/* ── Modal Footer ───────────────────────────────────────── */
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Toast Notifications ────────────────────────────────── */
#portalToast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    background-color: var(--primary);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 999;
    display: none;
    animation: fadeIn 0.2s ease;
}

#portalToast.toast-error {
    background-color: #991b1b;
}

#portalToast.toast-success {
    background-color: #065f46;
}

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

/* ── Print Optimization (@media print) ──────────────────── */
@media print {
    body {
        background-color: #ffffff !important;
        font-size: 11pt;
        color: #000000 !important;
    }
    
    .portal-header,
    .kpi-grid,
    .toolbar-wrap,
    .modal-close-btn,
    .modal-footer,
    #portalToast,
    .no-print {
        display: none !important;
    }
    
    .modal-overlay {
        position: static !important;
        background: none !important;
        padding: 0 !important;
        backdrop-filter: none !important;
    }
    
    .modal-dialog {
        max-width: 100% !important;
        box-shadow: none !important;
        border: none !important;
    }
    
    .modal-header {
        background-color: transparent !important;
        color: #000000 !important;
        border-bottom: 2px solid #000000 !important;
        padding: 0 0 10px 0 !important;
    }
    
    .modal-body {
        padding: 10px 0 !important;
    }
    
    .portal-table th,
    .portal-table td {
        border-color: #cccccc !important;
        color: #000000 !important;
    }
}
