/* Meyer Timber Supplier Portal
   Brand colours from meyertimber.com.au */

:root {
    --charcoal: #1E1E1E;
    --meyer-red: #C0392B;
    --meyer-red-dark: #A93226;
    --white: #FFFFFF;
    --light-grey: #F5F5F5;
    --medium-grey: #E0E0E0;
    --dark-grey: #666666;
    --success: #27AE60;
    --warning: #F39C12;
    --error: #E74C3C;
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
    font-family: var(--font-stack);
    font-size: 0.875rem;
    color: var(--charcoal);
    background: var(--light-grey);
    line-height: 1.5;
}

/* Nav */
.nav-bar {
    background: var(--charcoal);
    color: var(--white);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
}
.nav-inner {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--white);
}
.nav-logo {
    background: var(--meyer-red);
    color: var(--white);
    font-weight: 600;
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-title {
    font-size: 1rem;
    font-weight: 600;
}
.nav-subtitle {
    font-weight: 400;
    opacity: 0.7;
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.nav-user { opacity: 0.7; font-size: 0.8rem; }
.nav-link {
    color: var(--white);
    text-decoration: none;
    font-size: 0.8rem;
    opacity: 0.8;
    transition: opacity 0.15s;
}
.nav-link:hover { opacity: 1; }
.nav-logout-btn {
    background: none;
    border: none;
    font-family: var(--font-stack);
    cursor: pointer;
    padding: 0;
    color: var(--white);
    font-size: 0.8rem;
    opacity: 0.8;
    transition: opacity 0.15s;
}
.nav-logout-btn:hover { opacity: 1; }

/* Main content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Page header */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 600; }
.page-header h2 { font-size: 1.25rem; font-weight: 600; }
.breadcrumb { margin-bottom: 0.5rem; font-size: 0.8rem; }

h2 { font-size: 1.25rem; font-weight: 600; margin: 1.5rem 0 0.75rem; }

/* Cards */
.card {
    background: var(--white);
    border: 1px solid var(--medium-grey);
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Tables */
.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dark-grey);
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--medium-grey);
}
.table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--light-grey);
}
.table tbody tr:nth-child(even) { background: var(--light-grey); }
.table tbody tr:hover { background: #FAFAFA; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--white);
}
.badge-open, .badge-draft { background: var(--dark-grey); }
.badge-audit { background: var(--charcoal); font-size: 0.65rem; letter-spacing: 0.02em; }
.badge-in_progress, .badge-pending { background: var(--warning); }
.badge-approved, .badge-fulfilled { background: var(--success); }
.badge-closed, .badge-cancelled, .badge-rejected { background: var(--error); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--meyer-red); color: var(--white); }
.btn-primary:hover { background: var(--meyer-red-dark); }
.btn-secondary { background: var(--white); color: var(--charcoal); border: 1px solid var(--medium-grey); }
.btn-secondary:hover { border-color: var(--charcoal); }
.btn-danger { background: var(--error); color: var(--white); }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-disabled, .btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Forms */
.input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--medium-grey);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: var(--font-stack);
}
.input:focus { outline: none; border-color: var(--meyer-red); }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-weight: 500; font-size: 0.8rem; }
.form-group .input { width: 100%; }

/* Filter bar */
.filter-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-bar .input { flex: 1; min-width: 150px; }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.detail-label { display: block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dark-grey); margin-bottom: 0.15rem; }
.detail-value { font-size: 0.875rem; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 0.75rem; justify-content: center; padding-top: 1rem; }
.pagination-info { font-size: 0.8rem; color: var(--dark-grey); }

/* Links */
.link { color: var(--meyer-red); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 4px; margin-bottom: 1rem; font-size: 0.875rem; }
.alert-error { background: #FCEBEB; color: #791F1F; border: 1px solid #F7C1C1; }
.alert-success { background: #EAF3DE; color: #27500A; border: 1px solid #C0DD97; }
.alert-warning { background: #FAEEDA; color: #633806; border: 1px solid #FAC775; }
.alert-info { background: #E6F1FB; color: #0C447C; border: 1px solid #B5D4F4; }

/* Utility */
.text-secondary { color: var(--dark-grey); }
.text-center { text-align: center; }

/* Section header with inline button */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 1.5rem 0 0.75rem;
}
.section-header h2 { margin: 0; }

/* Action bar */
.action-bar {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

/* Form rows */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-group-wide { grid-column: span 1; }
.form-group textarea.input {
    width: 100%;
    resize: vertical;
    font-family: var(--font-stack);
}

/* Small inputs for table cells */
.input-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    width: 100px;
}

/* Detail item spanning full width */
.detail-item-wide { grid-column: 1 / -1; }

/* Card heading */
.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

/* Form actions */
.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Login page */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--charcoal);
}
.login-card {
    background: var(--white);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 380px;
}
.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.login-header .nav-logo {
    margin: 0 auto 0.75rem;
}
.login-header h1 { font-size: 1.25rem; font-weight: 600; }

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 1.5rem;
    font-size: 0.75rem;
    color: var(--dark-grey);
}

/* Notification bell */
.notif-wrapper { position: relative; }
.notif-bell-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--white);
    padding: 0;
    position: relative;
}
.notif-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--meyer-red);
    color: var(--white);
    font-size: 0.6rem;
    font-weight: 600;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notif-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: var(--white);
    border: 1px solid var(--medium-grey);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    margin-top: 8px;
}
.notif-dropdown-open { display: block; }
.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--medium-grey);
    color: var(--charcoal);
    font-size: 0.85rem;
}
.notif-mark-all {
    background: none;
    border: none;
    color: var(--meyer-red);
    cursor: pointer;
    font-size: 0.75rem;
    font-family: var(--font-stack);
}
.notif-dropdown-list {
    max-height: 320px;
    overflow-y: auto;
}
.notif-item {
    display: block;
    padding: 0.6rem 1rem;
    text-decoration: none;
    color: var(--charcoal);
    border-bottom: 1px solid var(--light-grey);
    transition: background 0.1s;
}
.notif-item:hover { background: var(--light-grey); }
.notif-unread { background: #FFF8F0; }
.notif-item-title { display: block; font-size: 0.8rem; font-weight: 500; }
.notif-item-time { display: block; font-size: 0.7rem; color: var(--dark-grey); margin-top: 2px; }
.notif-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--dark-grey);
    font-size: 0.8rem;
}
.notif-view-all {
    display: block;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--meyer-red);
    text-decoration: none;
    border-top: 1px solid var(--medium-grey);
}
.nav-proposals-badge {
    background: var(--meyer-red);
    color: var(--white);
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 999px;
    margin-left: 2px;
}

/* Notification list page */
.notif-list-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--charcoal);
    border-bottom: 1px solid var(--light-grey);
    transition: background 0.1s;
}
.notif-list-item:hover { background: var(--light-grey); }
.notif-list-item.notif-unread { background: #FFF8F0; }
.notif-list-item.notif-unread:hover { background: #FFF0E0; }
.notif-list-content { flex: 1; }
.notif-list-title { display: block; font-weight: 500; font-size: 0.875rem; }
.notif-list-message { display: block; font-size: 0.8rem; color: var(--dark-grey); margin-top: 2px; }
.notif-list-time { font-size: 0.75rem; color: var(--dark-grey); white-space: nowrap; margin-left: 1rem; }

/* Allocation row states */
.row-allocated td { color: #999; }
.row-allocated td .link { color: var(--meyer-red); opacity: 0.8; }
.row-cancelled td { color: #999; text-decoration: line-through; }
.row-cancelled td .badge { text-decoration: none; }
.row-cancelled td .link { text-decoration: none; }

/* Allocation badges */
.badge-available { background: var(--success); }
.badge-allocated { background: #3498DB; }

/* Production status badges */
.badge-po-planned { background: #95A5A6; }
.badge-po-in_production { background: #3498DB; }
.badge-po-produced { background: #8E44AD; }
.badge-po-ready_to_ship { background: #F39C12; }
.badge-po-shipped { background: #27AE60; }
.badge-po-received { background: #BDC3C7; color: var(--dark-grey); }

/* Received row (greyed out in all list views) */
.row-received td { color: #999; }
.row-received td .link { opacity: 0.6; }
.row-received td .badge { opacity: 0.7; }

/* Status update form inline */
.status-update-form { display: inline-flex; align-items: center; gap: 0.25rem; }

/* Inline edit controls (ETA, mfg date) */
.inline-edit-cell { min-width: 140px; }
.inline-edit-form { display: flex; align-items: center; gap: 0.25rem; }
.inline-edit-input { width: 130px; font-size: 0.85rem; padding: 0.15rem 0.3rem; }
.btn-inline-save {
    background: var(--success); color: white; border: none; border-radius: 3px;
    width: 24px; height: 24px; font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    line-height: 1; flex-shrink: 0;
}
.btn-inline-save:hover { opacity: 0.85; }

/* Checkbox column in MPO line table */
.col-check { width: 32px; text-align: center; }

/* Variance colours */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--error); }

/* Section header actions */
.section-header-actions { display: flex; gap: 0.5rem; }

/* Review form */
.review-form textarea.input {
    width: 100%;
    resize: vertical;
    font-family: var(--font-stack);
}

/* Telemetry dashboard */
.telem-summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}
.telem-summary-card {
    background: var(--white);
    border: 1px solid var(--medium-grey);
    border-radius: 4px;
    padding: 1rem;
    text-align: center;
}
.telem-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.telem-card-link:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.telem-card-danger { border-left: 4px solid var(--error); }
.telem-card-warning { border-left: 4px solid var(--warning); }
.telem-summary-number {
    display: block;
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.2;
}
.telem-summary-label {
    display: block;
    font-size: 0.75rem;
    color: var(--dark-grey);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.25rem;
}

/* Pipeline bar */
.telem-pipeline-bar {
    display: flex;
    height: 32px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}
.telem-pipeline-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--white);
    min-width: 20px;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s;
}
.telem-pipeline-segment:hover { opacity: 0.8; }
.telem-seg-planned { background: #95A5A6; }
.telem-seg-in_production { background: #3498DB; }
.telem-seg-produced { background: #8E44AD; }
.telem-seg-ready_to_ship { background: #F39C12; }
.telem-seg-shipped { background: #27AE60; }
.telem-seg-received { background: #BDC3C7; color: var(--dark-grey); }

.telem-pipeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--dark-grey);
}
.telem-legend-item { display: flex; align-items: center; gap: 0.35rem; }
.telem-legend-link { text-decoration: none; color: inherit; cursor: pointer; }
.telem-legend-link:hover { text-decoration: underline; }
.telem-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Activity feed */
.telem-activity-feed { max-height: 400px; overflow-y: auto; }
.telem-activity-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--light-grey);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.telem-activity-item:last-child { border-bottom: none; }
.telem-activity-details { font-size: 0.8rem; flex: 1; min-width: 200px; }
.telem-activity-meta {
    font-size: 0.7rem;
    color: var(--dark-grey);
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content { padding: 1rem; }
    .detail-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; }
    .telem-summary-row { grid-template-columns: repeat(2, 1fr); }
}
