/* AlfaPrint CRM & MIS Enterprise v1.0 - Industrial Offset & Bookbinding UI */
:root {
    /* --- Official AlfaPrint Corporate Identity Palette --- */
    --brand-primary: #7a1c79;
    --brand-primary-hover: #8b2288;
    --brand-accent: #b565b4;
    --brand-light: #e6e7e8;
    --brand-dark: #1e1b24;

    /* --- Theme Core Tokens --- */
    --primary: var(--brand-primary);
    --primary-hover: var(--brand-primary-hover);
    --bg-body: #f4f5f8;
    --bg-card: #ffffff;
    --bg-sidebar: var(--brand-dark);
    --bg-sidebar-hover: #2d2836;
    --text-main: var(--brand-dark);
    --text-muted: #5e5968;
    --text-light: #9a95a4;
    --border: var(--brand-light);

    /* --- CMYK Print Registration Colors --- */
    --cmyk-c: #00aeef;
    --cmyk-m: #ec008c;
    --cmyk-y: #fff200;
    --cmyk-k: var(--brand-dark);

    /* --- Semantic Accents --- */
    --emerald: #10b981;
    --amber: #f59e0b;
    --rose: #ef4444;
    --purple: #7a1c79;

    --radius: 10px;
    --shadow-sm: 0 1px 3px rgba(30, 27, 36, 0.06);
    --shadow-md: 0 6px 18px rgba(30, 27, 36, 0.08);
    --shadow-brand: 0 4px 14px rgba(122, 28, 121, 0.35);
}

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

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

/* CMYK Print Registration Top Bar */
.cmyk-strip {
    height: 4px;
    width: 100%;
    background: linear-gradient(90deg, var(--cmyk-c) 0%, var(--cmyk-c) 25%, var(--cmyk-m) 25%, var(--cmyk-m) 50%, var(--cmyk-y) 50%, var(--cmyk-y) 75%, var(--cmyk-k) 75%, var(--cmyk-k) 100%);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    padding-top: 4px;
}

/* Fixed Industrial Sidebar */
.app-sidebar {
    width: 268px;
    background: var(--bg-sidebar);
    color: #f8fafc;
    position: fixed;
    top: 4px;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 900;
    overflow-y: auto;
    border-right: 1px solid #1e293b;
}

.brand-box {
    padding: 16px 18px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-header-link {
    display: block;
    text-decoration: none;
}

.brand-logo {
    max-height: 44px;
    max-width: 200px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    transition: transform 0.15s ease;
}

.brand-logo:hover {
    transform: scale(1.02);
}

.brand-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: #fff;
    text-decoration: none;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 15px;
    color: #fff;
    box-shadow: 0 3px 10px rgba(122, 28, 121, 0.4);
}

.brand-sub {
    font-size: 11px;
    color: var(--brand-light);
    margin-top: 6px;
    display: block;
    opacity: 0.85;
}

.nav-section-title {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: #64748b;
    font-weight: 700;
    padding: 14px 18px 6px;
}

.nav-list {
    list-style: none;
    padding: 0 10px;
}

.nav-item a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    font-size: 13.5px;
    margin-bottom: 3px;
    transition: all 0.15s ease;
}

.nav-item a:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-item a.active {
    background: var(--brand-primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(122, 28, 121, 0.35);
}

.nav-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-pill {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11.5px;
    color: #94a3b8;
    background: rgba(2, 6, 23, 0.45);
}

.db-status-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 6px;
    color: #6ee7b7;
    font-weight: 600;
    font-size: 11.5px;
    margin-bottom: 8px;
}

.db-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

/* Main Content Area */
.app-main {
    margin-left: 268px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    height: 62px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 0 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 4px;
    z-index: 800;
}

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

.topbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-content {
    padding: 24px 26px 48px;
    max-width: 1680px;
}

/* Grid & Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary);
}

.kpi-card.emerald::before { background: var(--emerald); }
.kpi-card.amber::before { background: var(--amber); }
.kpi-card.purple::before { background: var(--purple); }
.kpi-card.rose::before { background: var(--rose); }

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.kpi-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-main);
    margin: 6px 0 4px;
}

.kpi-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #f8fafc;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 20px;
}

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

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-sidebar-right {
    display: grid;
    grid-template-columns: 1.55fr 1fr;
    gap: 20px;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

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

.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.font-mono { font-family: "JetBrains Mono", Consolas, monospace; }
.fw-bold { font-weight: 700; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-blue    { background: #dbeafe; color: #1e40af; }
.badge-indigo  { background: #e0e7ff; color: #3730a3; }
.badge-emerald { background: #d1fae5; color: #065f46; }
.badge-green   { background: #dcfce7; color: #166534; }
.badge-amber   { background: #fef3c7; color: #92400e; }
.badge-purple  { background: #ede9fe; color: #5b21b6; }
.badge-rose    { background: #ffe4e6; color: #9f1239; }
.badge-slate   { background: #e2e8f0; color: #334155; }
.badge-magenta,
.badge-brand   { background: #f8eaf7; color: var(--brand-primary); border: 1px solid rgba(122, 28, 121, 0.25); }
.badge-accent  { background: #fbf0fa; color: var(--brand-primary-hover); }

/* Buttons & Forms */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-brand,
.btn-magenta {
    background: var(--brand-primary);
    color: #fff;
}
.btn-brand:hover,
.btn-magenta:hover {
    background: var(--brand-primary-hover);
    color: #fff;
}

.btn-outline-brand {
    background: #fff;
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}
.btn-outline-brand:hover {
    background: var(--brand-primary);
    color: #fff;
}

.btn-emerald {
    background: var(--emerald);
    color: #fff;
}
.btn-emerald:hover { background: #059669; }

.btn-purple {
    background: var(--purple);
    color: #fff;
}
.btn-purple:hover { background: #6d28d9; }

.btn-outline {
    background: #fff;
    border-color: #cbd5e1;
    color: #1e293b;
}
.btn-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
}

.form-control {
    padding: 8px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 13.5px;
    color: var(--text-main);
    background: #fff;
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(122, 28, 121, 0.16);
}

/* Alerts & Progress */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13.5px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

.progress-bar-bg {
    height: 8px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 99px;
    background: var(--primary);
}

/* Production Stepper */
.stage-pipeline {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.stage-step-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    border-top: 3px solid var(--primary);
}

/* Book Spine 3D Preview Box */
.book-preview-box {
    background: linear-gradient(145deg, #0f172a, #1e293b);
    color: #f8fafc;
    border-radius: 10px;
    padding: 18px;
}

@media (max-width: 1100px) {
    .grid-2, .grid-3, .grid-sidebar-right {
        grid-template-columns: 1fr;
    }
    .stage-pipeline {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Modal Dialog (AlfaPrint Corporate Brand Identity) */
.crm-modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(30, 27, 36, 0.65);
    backdrop-filter: blur(3px);
    z-index: 1050;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.crm-modal-backdrop.is-open {
    display: flex;
}
.crm-modal-content {
    background: #ffffff;
    border-radius: var(--radius);
    max-width: 860px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 45px rgba(30, 27, 36, 0.35);
    border: 1px solid var(--border);
    animation: crmModalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes crmModalFadeIn {
    from { opacity: 0; transform: scale(0.96) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.crm-modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fbfbfc;
    border-top: 4px solid var(--brand-primary);
    border-radius: var(--radius) var(--radius) 0 0;
}
.crm-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--brand-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}
.crm-modal-close {
    background: transparent;
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
    transition: color 0.15s ease;
}
.crm-modal-close:hover {
    color: var(--brand-primary);
}
.crm-modal-body {
    padding: 24px;
}
.crm-modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    background: #fbfbfc;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Department & Category Filter Pills */
.dept-pills-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}
.dept-pill-btn {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.dept-pill-btn:hover {
    background: #f3f0f7;
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}
.dept-pill-btn.active {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
    box-shadow: 0 2px 8px rgba(122, 28, 121, 0.3);
}

/* Modal Form Grids */
.modal-form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.modal-fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 18px 18px;
    margin-bottom: 18px;
    background: #ffffff;
}
.modal-legend {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--brand-primary);
    padding: 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* KPI Summary Cards */
.kpi-summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.kpi-metric-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.kpi-metric-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--brand-primary);
}
.kpi-metric-card.accent-emerald::before { background: var(--emerald); }
.kpi-metric-card.accent-amber::before { background: var(--amber); }
.kpi-metric-card.accent-rose::before { background: var(--rose); }

.kpi-metric-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}
.kpi-metric-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--brand-dark);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.kpi-metric-sub {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Print Media Styles */
@media print {
    .cmyk-strip,
    .app-sidebar,
    .app-topbar,
    .btn,
    .no-print {
        display: none !important;
    }
    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 11pt;
    }
    .app-shell {
        display: block !important;
        padding-top: 0 !important;
    }
    .app-main {
        margin-left: 0 !important;
    }
    .app-content {
        padding: 0 !important;
        max-width: 100% !important;
    }
    .brand-print-header {
        background: var(--brand-dark) !important;
        color: #ffffff !important;
        padding: 12px 18px !important;
        border-radius: 6px;
        margin-bottom: 20px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

