/* Rawk Infinity Invoices — Wonderweb Technologies */

:root {
    --ri-bg: #f4f5f7;
    --ri-card: #ffffff;
    --ri-border: #e3e6ea;
    --ri-text: #1a1f2e;
    --ri-muted: #6b7280;
    --ri-brand: #0f2942;
    --ri-accent: #c9a227;
    --ri-success: #059669;
    --ri-warning: #d97706;
    --ri-danger: #dc2626;
}

/* ============ App shell ============ */
.ri-app { display: flex; min-height: 80vh; background: var(--ri-bg); border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }

.ri-nav { width: 220px; background: var(--ri-brand); color: #fff; display: flex; flex-direction: column; padding: 24px 16px; flex-shrink: 0; }
.ri-nav-brand { margin-bottom: 30px; display: flex; align-items: center; justify-content: center; min-height: 60px; }
.ri-nav-brand img { max-width: 100%; max-height: 60px; object-fit: contain; filter: brightness(0) invert(1); }
.ri-nav-brand-text { font-family: Georgia, serif; text-align: center; letter-spacing: 3px; font-weight: 700; font-size: 14px; line-height: 1.4; }
.ri-nav-links { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.ri-nav-links a { color: rgba(255,255,255,0.72); padding: 10px 14px; border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 500; transition: all 0.15s; }
.ri-nav-links a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.ri-nav-links a.active { background: rgba(255,255,255,0.14); color: #fff; }
.ri-nav-logout { margin-top: 20px; }

.ri-content { flex: 1; padding: 30px; overflow-x: auto; }

/* ============ Page head ============ */
.ri-page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.ri-page-head h1 { margin: 0 0 4px; font-size: 26px; font-weight: 700; color: var(--ri-text); }
.ri-muted { color: var(--ri-muted); font-size: 13px; margin: 0; }

/* ============ Buttons ============ */
.ri-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid var(--ri-border); background: #fff; color: var(--ri-text); text-decoration: none; transition: all 0.15s; line-height: 1.2; }
.ri-btn:hover { background: #f6f7f9; border-color: #c9ccd1; }
.ri-btn--primary { background: var(--ri-brand); border-color: var(--ri-brand); color: #fff; }
.ri-btn--primary:hover { background: #162f4a; border-color: #162f4a; color: #fff; }
.ri-btn--danger { color: var(--ri-danger); border-color: #fbd5d5; }
.ri-btn--danger:hover { background: #fef2f2; }
.ri-btn--ghost { background: transparent; }
.ri-btn--block { display: flex; width: 100%; }
.ri-btn--tiny { padding: 5px 10px; font-size: 12px; }

/* ============ Stats ============ */
.ri-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 28px; }
.ri-stat { background: #fff; border: 1px solid var(--ri-border); border-radius: 10px; padding: 18px; }
.ri-stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ri-muted); margin-bottom: 8px; }
.ri-stat-value { font-size: 22px; font-weight: 700; color: var(--ri-text); }

/* ============ Tables ============ */
.ri-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid var(--ri-border); }
.ri-table th, .ri-table td { padding: 12px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--ri-border); }
.ri-table th { background: #f8f9fa; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ri-muted); font-weight: 700; }
.ri-table tr:last-child td { border-bottom: none; }
.ri-table a { color: var(--ri-brand); text-decoration: none; font-weight: 600; }

/* ============ Badges ============ */
.ri-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.ri-badge--draft { background: #eef0f3; color: #4b5563; }
.ri-badge--sent { background: #e0f2fe; color: #0369a1; }
.ri-badge--partially_paid { background: #fef3c7; color: #92400e; }
.ri-badge--paid { background: #d1fae5; color: #065f46; }
.ri-badge--overdue { background: #fee2e2; color: #991b1b; }
.ri-badge--cancelled { background: #e5e7eb; color: #4b5563; }

/* ============ Notices ============ */
.ri-notice { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.ri-notice--success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.ri-notice--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ============ Forms ============ */
.ri-form--panel { background: #fff; border: 1px solid var(--ri-border); border-radius: 10px; padding: 24px; margin-bottom: 20px; }
.ri-form label, .ri-form--panel label { display: block; margin-bottom: 14px; }
.ri-form label span, .ri-form--panel label span { display: block; font-size: 12px; font-weight: 600; color: var(--ri-text); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.ri-form input[type=text], .ri-form input[type=email], .ri-form input[type=password], .ri-form input[type=number], .ri-form input[type=date], .ri-form input[type=tel],
.ri-form--panel input, .ri-form--panel select, .ri-form--panel textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--ri-border); border-radius: 8px; font-size: 14px; background: #fff; color: var(--ri-text); }
.ri-form--panel input:focus, .ri-form--panel select:focus, .ri-form--panel textarea:focus { outline: none; border-color: var(--ri-brand); box-shadow: 0 0 0 3px rgba(15,41,66,0.08); }
.ri-grid { display: grid; gap: 14px; }
.ri-grid--2 { grid-template-columns: 1fr 1fr; }
.ri-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 720px) { .ri-grid--2, .ri-grid--3 { grid-template-columns: 1fr; } .ri-nav { display: none; } .ri-content { padding: 16px; } }

.ri-form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.ri-sticky-actions { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--ri-border); padding: 14px 24px; margin: 0 -24px -24px; border-radius: 0 0 10px 10px; }

.ri-section-title { font-size: 16px; font-weight: 700; color: var(--ri-text); margin: 24px 0 12px; }
.ri-form--panel > .ri-section-title:first-child { margin-top: 0; }

/* ============ Empty state ============ */
.ri-empty { background: #fff; border: 1px dashed #d4d7dc; border-radius: 10px; padding: 40px; text-align: center; color: var(--ri-muted); font-size: 14px; }
.ri-empty a { color: var(--ri-brand); font-weight: 600; }

/* ============ Actions bar ============ */
.ri-actions { display: flex; gap: 8px; }
.ri-action-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; padding: 14px; background: #fff; border: 1px solid var(--ri-border); border-radius: 10px; }

/* ============ Invoice items editor ============ */
.ri-table-wrap { overflow-x: auto; margin-bottom: 12px; }
.ri-items-table { width: 100%; border-collapse: collapse; }
.ri-items-table th { background: #f8f9fa; padding: 10px; text-align: left; font-size: 11px; text-transform: uppercase; color: var(--ri-muted); font-weight: 700; }
.ri-items-table td { padding: 8px; border-bottom: 1px solid var(--ri-border); }
.ri-items-table input { width: 100%; padding: 8px 10px; border: 1px solid var(--ri-border); border-radius: 6px; font-size: 13px; }
.ri-line-total { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ri-row-remove { padding: 4px 10px; font-size: 16px; line-height: 1; }

.ri-vehicle-row { display: grid; grid-template-columns: 1.2fr 1.2fr 0.7fr 1.6fr 0.9fr 0.9fr 0.9fr auto; gap: 6px; margin-bottom: 6px; }
.ri-vehicle-row input { padding: 8px 10px; border: 1px solid var(--ri-border); border-radius: 6px; font-size: 13px; }
.ri-vin { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 12px; }
@media (max-width: 960px) { .ri-vehicle-row { grid-template-columns: 1fr 1fr; } }

.ri-totals-preview { margin-top: 16px; padding: 16px; background: #f8f9fa; border-radius: 8px; max-width: 320px; margin-left: auto; }
.ri-totals-preview > div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; color: var(--ri-muted); }
.ri-totals-preview > .ri-total-row { border-top: 1px solid var(--ri-border); margin-top: 6px; padding-top: 12px; font-size: 16px; color: var(--ri-text); font-weight: 700; }

.ri-inline-form { display: inline; }
.ri-inline-payment { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.ri-inline-payment input, .ri-inline-payment select { padding: 9px 12px; border: 1px solid var(--ri-border); border-radius: 8px; font-size: 13px; }

.ri-link-code { display: block; padding: 10px 12px; background: #f8f9fa; border: 1px solid var(--ri-border); border-radius: 8px; font-size: 12px; word-break: break-all; margin: 8px 0; }

/* ============ Login ============ */
.ri-login-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; background: linear-gradient(135deg, #0f2942 0%, #1a3a5c 100%); border-radius: 10px; }
.ri-login-card { background: #fff; border-radius: 14px; padding: 36px 32px; width: 100%; max-width: 400px; box-shadow: 0 20px 40px rgba(0,0,0,0.15); }
.ri-login-brand { text-align: center; margin-bottom: 28px; }
.ri-login-brand h1 { font-family: Georgia, serif; font-size: 22px; color: #0f2942; margin: 0 0 6px; }
.ri-login-brand p { font-size: 13px; color: #6b7280; margin: 0; }
.ri-login-card .ri-btn { margin-top: 8px; }
.ri-login-footer { text-align: center; font-size: 11px; color: #9ca3af; margin: 20px 0 0; }

/* ============ Filters ============ */
.ri-filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.ri-filters input, .ri-filters select { padding: 9px 12px; border: 1px solid var(--ri-border); border-radius: 8px; font-size: 13px; }

/* ============ Logo picker ============ */
.ri-logo-field { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; padding: 14px; border: 1px solid var(--ri-border); border-radius: 8px; background: #fafbfc; }
.ri-logo-preview { width: 100px; height: 70px; background: #fff; border: 1px solid var(--ri-border); border-radius: 6px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ri-logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.ri-logo-preview em { font-size: 11px; color: var(--ri-muted); }

.ri-checkbox { display: flex !important; align-items: center; gap: 8px; }
.ri-checkbox input { width: auto !important; }
.ri-checkbox span, .ri-checkbox { text-transform: none !important; letter-spacing: 0 !important; font-size: 13px !important; }

/* =====================================================================
   INVOICE DOCUMENT — the beautiful one
   ===================================================================== */
.ri-invoice-preview { background: #e9ebee; padding: 24px; border-radius: 10px; margin-bottom: 20px; }
.ri-public-page { background: #e9ebee; margin: 0; padding: 24px 12px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
.ri-public-wrap { max-width: 900px; margin: 0 auto; }

.ri-doc {
    background: #fff;
    padding: 44px 48px;
    max-width: 900px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #1a1f2e;
    font-size: 13px;
    line-height: 1.55;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.ri-doc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 24px;
    border-bottom: 3px solid var(--ri-brand, #0f2942);
    margin-bottom: 26px;
}
.ri-doc-brand { max-width: 55%; }
.ri-doc-logo { max-width: 220px; max-height: 90px; object-fit: contain; display: block; }
.ri-doc-logo-fallback { font-family: Georgia, serif; font-size: 22px; font-weight: 700; color: var(--ri-brand, #0f2942); letter-spacing: 0.02em; }
.ri-doc-tagline { font-size: 11px; color: #6b7280; margin-top: 8px; font-style: italic; }

.ri-doc-title { text-align: right; }
.ri-doc-title-label { font-family: Georgia, serif; font-size: 30px; font-weight: 700; color: var(--ri-brand, #0f2942); letter-spacing: 0.08em; line-height: 1; margin-bottom: 8px; }
.ri-doc-no { font-size: 15px; font-weight: 700; color: var(--ri-text); margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.ri-doc-dates { font-size: 11px; color: #6b7280; }
.ri-doc-dates div { margin-bottom: 2px; }
.ri-doc-dates span { display: inline-block; min-width: 50px; font-weight: 600; color: #374151; }

.ri-doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-bottom: 28px; }
.ri-doc-party-label { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; color: var(--ri-accent, #c9a227); margin-bottom: 8px; }
.ri-doc-party-name { font-size: 14px; font-weight: 700; color: var(--ri-text); margin-bottom: 4px; }
.ri-doc-party-line { font-size: 12px; color: #4b5563; margin-bottom: 1px; }

.ri-doc-section-title { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; color: var(--ri-brand, #0f2942); text-transform: uppercase; margin: 22px 0 10px; padding-bottom: 4px; border-bottom: 1px solid #e5e7eb; }

.ri-doc-vehicles { width: 100%; border-collapse: collapse; margin-bottom: 6px; border: 1px solid #e5e7eb; }
.ri-doc-vehicles th { background: #f8f9fa; padding: 8px 10px; text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #6b7280; border-bottom: 1px solid #e5e7eb; }
.ri-doc-vehicles td { padding: 9px 10px; font-size: 12px; border-bottom: 1px solid #f1f2f4; }
.ri-doc-vehicles tr:last-child td { border-bottom: none; }
.ri-mono { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 11px; letter-spacing: 0.02em; }

.ri-doc-items { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.ri-doc-items th { padding: 10px 8px; text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #6b7280; border-bottom: 1px solid #e5e7eb; }
.ri-doc-items td { padding: 11px 8px; font-size: 13px; border-bottom: 1px solid #f1f2f4; vertical-align: top; }
.ri-col-desc { width: 50%; }
.ri-col-qty { width: 10%; text-align: center; }
.ri-col-price, .ri-col-total { width: 20%; text-align: right; font-variant-numeric: tabular-nums; }
.ri-doc-items thead th.ri-col-price, .ri-doc-items thead th.ri-col-total { text-align: right; }

.ri-doc-totals { margin-top: 18px; margin-left: auto; width: 300px; padding-top: 14px; border-top: 2px solid var(--ri-brand, #0f2942); }
.ri-doc-total-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; color: #4b5563; }
.ri-doc-total-row strong { font-variant-numeric: tabular-nums; color: #1a1f2e; font-weight: 600; }
.ri-doc-total-row--grand { border-top: 1px solid #e5e7eb; margin-top: 6px; padding-top: 10px; font-size: 14px; font-weight: 700; color: var(--ri-text); }
.ri-doc-total-row--grand strong { font-size: 16px; color: var(--ri-brand, #0f2942); }
.ri-doc-total-row--balance { background: rgba(201,162,39,0.08); padding: 10px; margin: 6px -10px 0; border-radius: 6px; color: var(--ri-brand, #0f2942); font-weight: 700; }
.ri-doc-total-row--balance strong { font-size: 16px; color: var(--ri-accent, #c9a227); }

.ri-doc-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 30px; padding-top: 20px; border-top: 1px solid #e5e7eb; }
.ri-doc-pay-line { font-size: 12px; color: #4b5563; margin-bottom: 2px; }
.ri-doc-payment .ri-doc-section-title, .ri-doc-terms .ri-doc-section-title { margin-top: 0; }
.ri-doc-terms p { font-size: 12px; color: #4b5563; margin: 0 0 8px; }

.ri-doc-footer { margin-top: 30px; padding-top: 16px; border-top: 2px solid var(--ri-brand, #0f2942); text-align: center; }
.ri-doc-footer-zw { font-size: 11px; color: #6b7280; margin-bottom: 6px; }
.ri-doc-footer-tag { font-family: Georgia, serif; font-size: 13px; font-style: italic; color: var(--ri-brand, #0f2942); font-weight: 600; }

/* Watermark */
.ri-watermark { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-30deg); font-size: 140px; font-weight: 900; letter-spacing: 0.08em; opacity: 0.06; pointer-events: none; user-select: none; z-index: 0; }
.ri-watermark--paid { color: #059669; }
.ri-watermark--overdue { color: #dc2626; }
.ri-watermark--draft { color: #6b7280; }

/* ============ Print ============ */
@media print {
    #wpadminbar, .ri-nav, .ri-action-bar, .ri-page-head, .ri-notice, .ri-btn, .ri-filters { display: none !important; }
    body, .ri-app, .ri-content, .ri-invoice-preview, .ri-public-page, .ri-public-wrap { background: #fff !important; margin: 0 !important; padding: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
    .ri-doc { box-shadow: none; padding: 15mm; margin: 0; max-width: none; }
    @page { size: A4; margin: 0; }
}

/* ============ Responsive ============ */
@media (max-width: 700px) {
    .ri-doc { padding: 28px 22px; }
    .ri-doc-head { flex-direction: column; gap: 16px; }
    .ri-doc-brand, .ri-doc-title { max-width: 100%; text-align: left; }
    .ri-doc-title { text-align: left; }
    .ri-doc-parties, .ri-doc-bottom { grid-template-columns: 1fr; gap: 20px; }
    .ri-doc-totals { width: 100%; }
}

