/* ==========================================================================
   Zimcore Media Platform — Core Theme
   Palette: crimson #fe2c55 / #d83a65, ink #13060a / #2e0a14 / #0a0607,
            blush #E6CACC (for light surfaces / subtle fills)
   ========================================================================== */

:root {
    --crimson: #fe2c55;
    --crimson-dark: #d83a65;
    --ink: #13060a;
    --ink-alt: #2e0a14;
    --black: #0a0607;
    --blush: #E6CACC;

    --surface: #ffffff;
    --surface-muted: #faf6f6;
    --border: #ece1e2;
    --text: #1c1114;
    --text-muted: #6d5a5e;

    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(10, 6, 7, 0.06);
    --shadow-md: 0 8px 24px rgba(10, 6, 7, 0.10);

    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--surface-muted);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.08s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: linear-gradient(135deg, var(--crimson), var(--crimson-dark));
    color: #fff;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-block { width: 100%; }

/* ==========================================================================
   Auth screen
   ========================================================================== */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 20%, rgba(254, 44, 85, 0.20), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(216, 58, 101, 0.18), transparent 45%),
        var(--ink);
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 36px 32px;
}
.auth-logo { display: block; max-width: 200px; margin: 0 auto 28px; }
.auth-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 16px 0 6px;
}
.auth-form input[type="text"],
.auth-form input[type="password"] {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--surface-muted);
}
.auth-form input:focus {
    outline: none;
    border-color: var(--crimson);
    box-shadow: 0 0 0 3px rgba(254, 44, 85, 0.15);
}
.password-field {
    position: relative;
    display: flex;
    align-items: center;
}
.password-field input[type="password"],
.password-field input[type="text"] {
    width: 100%;
    padding: 11px 70px 11px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--surface-muted);
}
.password-field input:focus {
    outline: none;
    border-color: var(--crimson);
    box-shadow: 0 0 0 3px rgba(254, 44, 85, 0.15);
}
.toggle-password {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--crimson-dark);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 8px;
}
.toggle-password:hover { color: var(--crimson); }

.auth-remember {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-weight: 500 !important;
    color: var(--text) !important;
}
.auth-remember input { width: auto; }
.auth-form .btn { margin-top: 24px; }
.alert {
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 8px;
}
.alert-error { background: #fdeceb; color: #b3261e; border: 1px solid #f4c7c3; }

/* ==========================================================================
   App shell
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--ink);
    color: #f3e6e8;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.2s ease;
}
.sidebar-brand { padding: 22px 20px 10px; }
.sidebar-brand img { max-width: 150px; filter: brightness(0) invert(1); opacity: 0.95; }

.sidebar-nav { flex: 1; padding: 8px 12px; }
.nav-group-label {
    font-size: 11px;
    letter-spacing: 0.08em;
    color: #a9848c;
    margin: 18px 10px 6px;
    font-weight: 700;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: #ecd8db;
    margin-bottom: 2px;
}
.nav-link:hover { background: rgba(254, 44, 85, 0.14); }
.nav-link.active {
    background: linear-gradient(135deg, var(--crimson), var(--crimson-dark));
    color: #fff;
    font-weight: 600;
}
.nav-icon { font-size: 10px; opacity: 0.8; }

.sidebar-footer {
    padding: 14px 16px 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user-name { font-weight: 600; font-size: 14px; }
.sidebar-user-role { font-size: 12px; color: #a9848c; margin-bottom: 10px; text-transform: capitalize; }
.nav-link-logout { color: #ff8f9c; padding-left: 12px; }

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}
.page-title { font-size: 19px; font-weight: 700; margin: 0; }
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text);
}
.topbar-spacer { flex: 1; }

.content { padding: 24px; }

/* ---------- Dashboard cards ---------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.summary-card .label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
}
.summary-card .value {
    font-size: 26px;
    font-weight: 800;
    margin-top: 6px;
    color: var(--ink);
}
.summary-card .value .currency-tag {
    font-size: 12px;
    font-weight: 700;
    color: var(--crimson);
    vertical-align: middle;
    margin-left: 6px;
}
.summary-card.accent {
    background: linear-gradient(135deg, var(--crimson), var(--crimson-dark));
    border: none;
}
.summary-card.accent .label,
.summary-card.accent .value { color: #fff; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.panel h2 { font-size: 15px; margin: 0 0 14px; }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 30px 10px;
    font-size: 14px;
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.badge-usd { background: #e8f4ee; color: #1e7f4f; }
.badge-zig { background: #fdeceb; color: var(--crimson-dark); }

/* ==========================================================================
   Phase 2 — Data tables, forms, modals, status badges
   ========================================================================== */

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-muted); }
.btn-danger { background: #b3261e; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 14px;
}
.data-table th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 10px 14px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .table-scroll { overflow-x: auto; }
.table-scroll { overflow-x: auto; }

.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: capitalize;
}
.status-draft     { background: #ece7e8; color: #5c4a4d; }
.status-sent      { background: #e5eefc; color: #1f5fbf; }
.status-accepted  { background: #e8f4ee; color: #1e7f4f; }
.status-rejected  { background: #fdeceb; color: #b3261e; }
.status-expired   { background: #f4ece2; color: #9a6b1e; }
.status-converted { background: #f1e9fb; color: #6a3fb3; }
.status-active    { background: #e8f4ee; color: #1e7f4f; }
.status-inactive  { background: #ece7e8; color: #5c4a4d; }

/* ---------- Forms (admin pages, not the login form) ---------- */
.field-group { margin-bottom: 16px; }
.field-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.field-group input,
.field-group select,
.field-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface-muted);
    font-family: inherit;
}
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
    outline: none;
    border-color: var(--crimson);
    box-shadow: 0 0 0 3px rgba(254, 44, 85, 0.15);
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }

/* ---------- Modal ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 6, 7, 0.55);
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--surface);
    border-radius: 14px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: var(--shadow-md);
}
.modal-box h2 { margin: 0 0 18px; font-size: 17px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- Line-item rows (quote builder) ---------- */
.line-items-table input,
.line-items-table select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--surface-muted);
    width: 100%;
}
.line-items-table .qty-input { max-width: 70px; }
.line-items-table .rate-input { max-width: 110px; }
.remove-line-btn {
    background: none;
    border: none;
    color: #b3261e;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px 8px;
}

/* ==========================================================================
   Printable documents (Quotes = blue theme, Invoices later = crimson theme)
   ========================================================================== */
.doc-page {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    padding: 40px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}
.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px solid var(--doc-accent, var(--crimson));
    padding-bottom: 20px;
    margin-bottom: 24px;
}
.doc-header img { max-width: 170px; }
.doc-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--doc-accent, var(--crimson));
    text-align: right;
}
.doc-meta { font-size: 13px; color: var(--text-muted); text-align: right; margin-top: 6px; }
.doc-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 26px;
}
.doc-parties h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0 0 8px;
}
.doc-parties p { margin: 0; font-size: 14px; line-height: 1.6; }
.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.doc-table th {
    background: var(--doc-accent, var(--crimson));
    color: #fff;
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    text-transform: uppercase;
}
.doc-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.doc-table .num { text-align: right; }
.doc-totals { margin-left: auto; width: 280px; }
.doc-totals div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.doc-totals .grand-total {
    font-weight: 800;
    font-size: 17px;
    border-top: 2px solid var(--doc-accent, var(--crimson));
    padding-top: 10px;
    margin-top: 6px;
    color: var(--doc-accent, var(--crimson));
}
.doc-terms { margin-top: 30px; font-size: 12px; color: var(--text-muted); line-height: 1.7; }
.doc-signature { margin-top: 50px; display: flex; justify-content: space-between; }
.doc-signature .line { border-top: 1px solid var(--text); width: 220px; padding-top: 6px; font-size: 12px; color: var(--text-muted); }
.doc-footer { margin-top: 40px; text-align: center; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 16px; }
.doc-toolbar { max-width: 800px; margin: 0 auto 16px; display: flex; gap: 10px; justify-content: flex-end; }

@media print {
    body * { visibility: hidden; }
    .doc-page, .doc-page * { visibility: visible; }
    .doc-page { position: absolute; top: 0; left: 0; width: 100%; box-shadow: none; padding: 0; margin: 0; }
    .doc-toolbar, .sidebar, .topbar { display: none !important; }
}
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        z-index: 20;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .content { padding: 16px; }
}

/* ==========================================================================
   Phase 2 additions — Customers / Services / Quotes list & form pages
   ========================================================================== */

.alert-success { background: #e8f6ee; color: #1e7f4f; border: 1px solid #bfe6cf; }

.panel-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}
.panel-title-lg { font-size: 20px; font-weight: 800; margin: 0; color: var(--ink); }

.table-wrap { overflow-x: auto; }

.badge-active { background: #e8f6ee; color: #1e7f4f; }
.badge-inactive { background: #f1eceb; color: #8a7377; }

.muted { color: var(--text-muted); font-style: italic; }

.btn-link {
    background: none;
    border: none;
    color: var(--crimson-dark);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}
.btn-link:hover { color: var(--crimson); text-decoration: underline; }

/* Modal (used by Customers "Add" and Services "Add/Edit") */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 6, 7, 0.55);
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: #fff;
    border-radius: 14px;
    padding: 26px;
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}
.modal h3 { margin: 0 0 18px; font-size: 17px; }
.modal label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 14px 0 6px;
}
.modal input[type="text"],
.modal input[type="email"],
.modal input[type="number"],
.modal input[type="date"],
.modal select,
.modal textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface-muted);
    font-family: inherit;
}
.modal input:focus, .modal select:focus, .modal textarea:focus {
    outline: none;
    border-color: var(--crimson);
    box-shadow: 0 0 0 3px rgba(254, 44, 85, 0.15);
}

/* Generic form building blocks used on the Services modal and Quote builder page */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}
form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 14px 0 6px;
}
.panel > form input[type="text"],
.panel > form input[type="email"],
.panel > form input[type="number"],
.panel > form input[type="date"],
.panel > form select,
.panel > form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface-muted);
    font-family: inherit;
    box-sizing: border-box;
}
.panel > form select {
    /* Normalize native select appearance so its height/vertical text
       position matches text inputs exactly across browsers. */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    height: 42px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%236d5a5e'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.panel > form input:focus, .panel > form select:focus, .panel > form textarea:focus {
    outline: none;
    border-color: var(--crimson);
    box-shadow: 0 0 0 3px rgba(254, 44, 85, 0.15);
}
.panel h2 { margin-top: 0; }

@media (min-width: 641px) and (max-width: 900px) {
    /* Keep Quote Details' two-column pairs (Customer/Currency,
       Billing Type/Valid Until) side-by-side on tablet widths instead of
       collapsing to a single cramped column. */
    .panel > form .form-row {
        grid-template-columns: 1fr 1fr;
    }
}

/* Quote line-item builder rows */
.line-item-row {
    display: grid;
    grid-template-columns: 1.6fr 1.6fr 0.7fr 0.6fr 0.8fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}
.line-item-row select,
.line-item-row input {
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: var(--surface-muted);
    width: 100%;
}
.li-line-total { text-align: right; font-weight: 700; font-size: 14px; color: var(--ink); }
.li-remove {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--crimson-dark);
    font-size: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
}
.li-remove:hover { background: #fdeceb; }

.quote-totals-preview {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    text-align: right;
    font-size: 15px;
}
.quote-totals-note { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

#submitQuote { margin: 20px 0 40px; }

@media (max-width: 700px) {
    .line-item-row {
        grid-template-columns: 1fr 1fr;
        grid-template-areas: "service service" "desc desc" "price qty" "total remove";
    }
}

/* ==========================================================================
   Phase 5 additions — Projects & Milestones progress bars
   ========================================================================== */
.progress-track {
    width: 100%;
    height: 8px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--crimson), var(--crimson-dark));
    border-radius: 999px;
    transition: width 0.2s ease;
}
.progress-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 4px;
    display: block;
}
