/* ================================================
   SUNDRAPE ORDER MANAGEMENT SYSTEM
   Brand Colors & Shared Styles
   ================================================ */

:root {
    --sd-primary: #0C4426;
    --sd-primary-light: #1a6b3d;
    --sd-primary-dark: #082e1a;
    --sd-accent: #F56800;
    --sd-accent-hover: #d95d00;
    --sd-dark: #080808;
    --sd-gray-dark: #333333;
    --sd-gray: #5f6360;
    --sd-gray-light: #8F8F8F;
    --sd-border: #E2E2E2;
    --sd-bg: #f4f6f5;
    --sd-white: #FFFFFF;
    --sd-success: #1a8c4e;
    --sd-warning: #e6a817;
    --sd-danger: #d9534f;
    --sd-info: #3a7ca5;
    --sidebar-width: 260px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--sd-bg);
    color: var(--sd-dark);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--sd-primary);
    text-decoration: none;
}
a:hover {
    color: var(--sd-primary-light);
}

/* ================================================
   SIDEBAR
   ================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sd-primary-dark);
    color: var(--sd-white);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo img {
    height: 36px;
    filter: brightness(0) invert(1);
}

.sidebar-logo span {
    font-size: 11px;
    opacity: 0.6;
    display: block;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.sidebar-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.4);
    padding: 12px 12px 6px;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,0.75);
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.08);
    color: var(--sd-white);
}
.sidebar-link.active {
    background: rgba(255,255,255,0.12);
    color: var(--sd-white);
}
.sidebar-link .icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    opacity: 0.8;
}
.sidebar-link.active .icon {
    opacity: 1;
}

.sidebar-link .badge-count {
    margin-left: auto;
    background: var(--sd-accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer .avatar {
    width: 34px;
    height: 34px;
    background: var(--sd-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: white;
}

.sidebar-footer .user-info {
    flex: 1;
}

.sidebar-footer .user-name {
    font-size: 13px;
    font-weight: 600;
}

.sidebar-footer .user-role {
    font-size: 11px;
    opacity: 0.5;
}

/* ================================================
   MAIN CONTENT
   ================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    background: var(--sd-white);
    border-bottom: 1px solid var(--sd-border);
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.topbar-left h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--sd-dark);
}

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--sd-gray-light);
}
.breadcrumb-nav a {
    color: var(--sd-gray-light);
}
.breadcrumb-nav a:hover {
    color: var(--sd-primary);
}
.breadcrumb-nav .sep {
    opacity: 0.4;
}

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

.topbar-search {
    position: relative;
}

.topbar-search input {
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--sd-border);
    border-radius: 8px;
    font-size: 13px;
    width: 240px;
    background: var(--sd-bg);
    transition: border-color 0.15s;
}
.topbar-search input:focus {
    outline: none;
    border-color: var(--sd-primary);
}
.topbar-search .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sd-gray-light);
    font-size: 14px;
}

.topbar-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    color: var(--sd-gray);
    position: relative;
    transition: background 0.15s;
}
.topbar-icon:hover {
    background: var(--sd-bg);
}
.topbar-icon .notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--sd-accent);
    border-radius: 50%;
    border: 2px solid white;
}

.page-content {
    padding: 28px 32px;
}

/* ================================================
   CARDS
   ================================================ */
.card {
    background: var(--sd-white);
    border: 1px solid var(--sd-border);
    border-radius: 12px;
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--sd-dark);
}

.card-body {
    padding: 20px;
}

/* ================================================
   KPI CARDS
   ================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--sd-white);
    border: 1px solid var(--sd-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.kpi-icon.green { background: #e8f5ee; color: var(--sd-primary); }
.kpi-icon.orange { background: #fff3e6; color: var(--sd-accent); }
.kpi-icon.blue { background: #e6f0f7; color: var(--sd-info); }
.kpi-icon.red { background: #fce8e8; color: var(--sd-danger); }

.kpi-content h4 {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--sd-dark);
}

.kpi-content p {
    font-size: 12.5px;
    color: var(--sd-gray);
    margin-top: 2px;
}

.kpi-trend {
    font-size: 11.5px;
    font-weight: 600;
    margin-top: 4px;
}
.kpi-trend.up { color: var(--sd-success); }
.kpi-trend.down { color: var(--sd-danger); }

/* ================================================
   TABLES
   ================================================ */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--sd-gray);
    background: var(--sd-bg);
    border-bottom: 1px solid var(--sd-border);
    white-space: nowrap;
}

table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13.5px;
    vertical-align: middle;
}

table tbody tr {
    transition: background 0.1s;
}

table tbody tr:hover {
    background: #fafbfa;
}

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

table tbody tr.clickable {
    cursor: pointer;
}

/* ================================================
   STATUS BADGES
   ================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-concept {
    background: #f0f0f0;
    color: var(--sd-gray);
}

.badge-verstuurd {
    background: #e6f0f7;
    color: var(--sd-info);
}

.badge-productie {
    background: #fff3e6;
    color: #c55a00;
}

.badge-deels {
    background: #fef7e0;
    color: #b8860b;
}

.badge-gereed {
    background: #e8f5ee;
    color: var(--sd-success);
}

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

.badge-concept .badge-dot { background: var(--sd-gray-light); }
.badge-verstuurd .badge-dot { background: var(--sd-info); }
.badge-productie .badge-dot { background: var(--sd-accent); }
.badge-deels .badge-dot { background: #b8860b; }
.badge-gereed .badge-dot { background: var(--sd-success); }

/* ================================================
   BUTTONS
   ================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

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

.btn-accent {
    background: var(--sd-accent);
    color: white;
}
.btn-accent:hover {
    background: var(--sd-accent-hover);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--sd-border);
    color: var(--sd-gray-dark);
}
.btn-outline:hover {
    border-color: var(--sd-gray-light);
    background: var(--sd-bg);
}

.btn-ghost {
    background: transparent;
    color: var(--sd-gray);
    padding: 6px 10px;
}
.btn-ghost:hover {
    background: var(--sd-bg);
    color: var(--sd-dark);
}

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

.btn-lg {
    padding: 11px 22px;
    font-size: 14px;
}

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

.btn-success {
    background: var(--sd-success);
    color: white;
}
.btn-success:hover {
    background: #157a42;
}

/* ================================================
   FORMS
   ================================================ */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--sd-gray-dark);
    margin-bottom: 5px;
}

.form-group label .required {
    color: var(--sd-danger);
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--sd-border);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--sd-dark);
    background: white;
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--sd-primary);
    box-shadow: 0 0 0 3px rgba(12, 68, 38, 0.1);
}

select.form-control {
    appearance: auto;
}

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

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

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

/* ================================================
   FILTERS BAR
   ================================================ */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--sd-border);
    flex-wrap: wrap;
}

.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--sd-bg);
    border-radius: 8px;
    padding: 3px;
}

.filter-tab {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--sd-gray);
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: transparent;
}

.filter-tab:hover {
    color: var(--sd-dark);
}

.filter-tab.active {
    background: white;
    color: var(--sd-dark);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.filter-tab .count {
    margin-left: 4px;
    font-weight: 500;
    opacity: 0.5;
}

/* ================================================
   ORDER DETAIL
   ================================================ */
.order-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.order-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.order-title h1 {
    font-size: 22px;
    font-weight: 700;
}

.order-meta {
    display: flex;
    gap: 24px;
    margin-top: 8px;
}

.order-meta-item {
    font-size: 13px;
    color: var(--sd-gray);
}

.order-meta-item strong {
    color: var(--sd-gray-dark);
}

.order-actions {
    display: flex;
    gap: 8px;
}

.order-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--sd-border);
    margin-bottom: 24px;
}

.order-tab {
    padding: 10px 20px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--sd-gray);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.order-tab:hover {
    color: var(--sd-dark);
}

.order-tab.active {
    color: var(--sd-primary);
    border-bottom-color: var(--sd-primary);
}

/* ================================================
   PRODUCT LINES TABLE (order detail)
   ================================================ */
.product-line-check {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    accent-color: var(--sd-primary);
    cursor: pointer;
}

.line-received {
    opacity: 0.5;
    text-decoration: line-through;
}

/* ================================================
   TIMELINE / MAIL
   ================================================ */
.timeline {
    position: relative;
    padding-left: 28px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--sd-border);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-dot {
    position: absolute;
    left: -28px;
    top: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
}

.timeline-dot.green { background: var(--sd-success); }
.timeline-dot.blue { background: var(--sd-info); }
.timeline-dot.orange { background: var(--sd-accent); }
.timeline-dot.gray { background: var(--sd-gray-light); }

.timeline-content {
    background: white;
    border: 1px solid var(--sd-border);
    border-radius: 10px;
    padding: 14px 16px;
}

.timeline-content .timeline-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.timeline-content .timeline-title {
    font-weight: 600;
    font-size: 13.5px;
}

.timeline-content .timeline-date {
    font-size: 12px;
    color: var(--sd-gray-light);
}

.timeline-content .timeline-body {
    font-size: 13px;
    color: var(--sd-gray);
    line-height: 1.6;
}

/* ================================================
   MAIL PREVIEW
   ================================================ */
.mail-item {
    padding: 14px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: background 0.1s;
}

.mail-item:hover {
    background: #fafbfa;
}

.mail-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 15px;
}

.mail-icon.incoming {
    background: #e6f0f7;
    color: var(--sd-info);
}

.mail-icon.outgoing {
    background: #e8f5ee;
    color: var(--sd-primary);
}

.mail-content {
    flex: 1;
    min-width: 0;
}

.mail-subject {
    font-weight: 600;
    font-size: 13.5px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-preview {
    font-size: 12.5px;
    color: var(--sd-gray-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-meta {
    text-align: right;
    flex-shrink: 0;
}

.mail-date {
    font-size: 11.5px;
    color: var(--sd-gray-light);
}

/* ================================================
   EMPTY STATE
   ================================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--sd-gray-light);
}

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

.empty-state h3 {
    font-size: 16px;
    color: var(--sd-gray);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 13px;
    max-width: 360px;
    margin: 0 auto;
}

/* ================================================
   LOGIN PAGE
   ================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--sd-primary-dark) 0%, var(--sd-primary) 50%, var(--sd-primary-light) 100%);
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    text-align: center;
}

.login-card img {
    height: 44px;
    margin-bottom: 8px;
}

.login-card .login-subtitle {
    font-size: 13px;
    color: var(--sd-gray);
    margin-bottom: 32px;
}

.login-card .form-group {
    text-align: left;
}

.login-card .btn-primary {
    width: 100%;
    padding: 11px;
    font-size: 14px;
    margin-top: 8px;
}

.login-footer {
    margin-top: 20px;
    font-size: 12px;
    color: var(--sd-gray-light);
}

/* ================================================
   PROGRESS BAR
   ================================================ */
.progress-bar-wrap {
    height: 6px;
    background: var(--sd-border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-bar-fill.green { background: var(--sd-success); }
.progress-bar-fill.orange { background: var(--sd-accent); }
.progress-bar-fill.blue { background: var(--sd-info); }

/* ================================================
   UTILITIES
   ================================================ */
.text-muted { color: var(--sd-gray-light); }
.text-success { color: var(--sd-success); }
.text-danger { color: var(--sd-danger); }
.text-accent { color: var(--sd-accent); }
.text-primary { color: var(--sd-primary); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-sm { font-size: 12px; }
.fs-xs { font-size: 11px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-2 { gap: 16px; }
.gap-1 { gap: 8px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ================================================
   MOBILE MENU BUTTON
   ================================================ */
.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--sd-dark);
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    flex-shrink: 0;
}
.mobile-menu-btn:hover {
    background: var(--sd-bg);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}
.sidebar-overlay.active {
    display: block;
}

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    }

    .main-content {
        margin-left: 0;
    }

    .topbar {
        padding: 0 16px;
        height: 56px;
    }

    .topbar-search {
        display: none;
    }

    .topbar-left h1 {
        font-size: 16px;
    }

    .page-content {
        padding: 16px;
    }

    .form-row, .form-row-3, .grid-2 {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .kpi-card {
        padding: 14px;
    }

    .kpi-content h4 {
        font-size: 20px;
    }

    .order-header {
        flex-direction: column;
        gap: 12px;
    }

    .order-actions {
        flex-wrap: wrap;
    }

    .order-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .order-tab {
        padding: 10px 14px;
        font-size: 12.5px;
        white-space: nowrap;
    }

    .order-meta {
        flex-direction: column;
        gap: 6px;
    }

    .filters-bar {
        padding: 12px 16px;
    }

    .filter-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    table thead th,
    table tbody td {
        padding: 10px 10px;
        font-size: 12.5px;
    }

    .card-header {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .card-body {
        padding: 16px;
    }

    .btn-lg {
        padding: 10px 16px;
        font-size: 13px;
    }

    /* Stacked buttons on mobile for order-new bottom */
    .page-content > div:last-child {
        flex-wrap: wrap;
    }

    .timeline-content .timeline-header {
        flex-direction: column;
        gap: 2px;
    }

    .mail-item {
        padding: 12px 16px;
    }

    .mail-preview {
        display: none;
    }

    /* Login responsive */
    .login-card {
        margin: 16px;
        padding: 32px 24px;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .order-actions .btn span.btn-label {
        display: none;
    }

    .topbar-left h1 {
        font-size: 14px;
    }

    /* Orderstatus grid stacked */
    .page-content .card-body > div[style*="grid-template-columns: repeat(5"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
