/**
 * Furever Friends Invoice Manager — Invoice Builder Canvas Styles
 * Preserves exact branding variables, canvas dimensions, typography, and controls.
 */

:root {
    --bg-cream: #FAF4EB;
    --primary-brown: #4A2E18;
    --brand-orange: #E46813;
    --brand-orange-light: #FCEBD9;
    --brand-orange-pill: #F7BA4C;
    --brand-pill-text: #593504;
    --border-color: #EBDBC8;
    --text-muted: #6F6257;
    --danger-red: #C53030;
    --badge-bg: #F5E6D3;
    --badge-border: #D9A066;
}

body.ff-preview-body { 
    background: #555; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    padding: 20px 10px; 
    margin: 0; 
    font-family: 'Nunito', sans-serif;
    box-sizing: border-box;
}
body.ff-preview-body * {
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
}

.ff-wrapper * { 
    box-sizing: border-box; 
    font-family: 'Nunito', sans-serif; 
}
.ff-wrapper { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    width: 100%; 
}

.ff-actions-bar {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.ff-btn-group { 
    display: flex; 
    gap: 8px; 
    flex-wrap: wrap; 
}

/* Active Edit Indicator Banner */
.ff-editing-banner {
    width: 100%;
    max-width: 800px;
    background: #FFF8E7;
    border: 1px solid #F7BA4C;
    border-radius: 8px;
    padding: 10px 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 6px rgba(247, 186, 76, 0.15);
}
.ff-editing-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ff-editing-tag {
    font-size: 11px;
    font-weight: 800;
    background: #E46813;
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.ff-editing-num {
    font-size: 14px;
    font-weight: 800;
    color: #4A2E18;
}
.ff-editing-note {
    font-size: 12px;
    color: #888;
}
.ff-btn-new-invoice {
    background: #fff;
    border: 1px solid #E46813;
    color: #E46813;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.ff-btn-new-invoice:hover {
    background: #E46813;
    color: #fff;
}

.ff-invoice-sheet {
    width: 100%;
    max-width: 800px;
    min-height: 1130px;
    background: var(--bg-cream);
    box-shadow: 0 4px 22px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: var(--primary-brown);
    position: relative;
    border-radius: 4px;
    overflow: hidden;
}
.ff-body { 
    padding: 40px 48px 24px; 
    flex-grow: 1; 
}

.ff-header { 
    text-align: center; 
    margin-bottom: 14px; 
}
.ff-header-logo { 
    max-height: 72px; 
    object-fit: contain; 
    cursor: pointer; 
}
.ff-header-text-logo { 
    font-family: 'Fredoka', cursive; 
    font-size: 26px; 
    font-weight: 700; 
    color: var(--primary-brown); 
}
.ff-tagline { 
    font-family: 'Fredoka', cursive; 
    font-weight: 700; 
    font-size: 18px; 
    line-height: 1.2;
    color: var(--primary-brown); 
    margin-top: 4px; 
}
.ff-tagline span { 
    color: var(--brand-orange); 
}

.ff-meta-grid { 
    display: flex; 
    justify-content: space-between; 
    gap: 24px; 
    margin-bottom: 16px; 
}
.ff-meta-col-left { 
    width: 55%; 
}
#clientName {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-brown);
    line-height: 1.3;
    margin-bottom: 3px;
}
#clientAddress {
    font-size: 13px;
    font-weight: 400;
    color: var(--primary-brown);
    line-height: 1.4;
    margin-bottom: 3px;
    white-space: pre-line;
}
#clientPhone {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.3;
}
.ff-meta-col-right { 
    width: 42%; 
}
.ff-sec-heading { 
    font-weight: 800; 
    font-size: 15px; 
    margin-bottom: 6px; 
}

.ff-client-select {
    width: 100%;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid #d0c0b0;
    border-radius: 4px;
    padding: 4px 6px;
    background: #fff;
    margin-bottom: 8px;
    color: var(--primary-brown);
}

.ff-meta-table { 
    width: 100%; 
    border-collapse: collapse; 
}
.ff-meta-table td { 
    padding: 3px 0; 
    font-size: 14px; 
}
.ff-meta-table td.label { 
    width: 115px; 
    font-weight: 700; 
}
.ff-inv-num { 
    font-weight: 800; 
    color: var(--brand-orange); 
}
.ff-status-pill { 
    background: var(--brand-orange-pill); 
    color: var(--brand-pill-text); 
    font-size: 11px; 
    font-weight: 800; 
    padding: 3px 10px; 
    border-radius: 12px; 
    display: inline-block; 
}

.ff-items-table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-bottom: 16px; 
    table-layout: fixed; 
}
.ff-items-table th { 
    background: #D9A066; 
    color: var(--primary-brown); 
    padding: 8px 12px; 
    font-size: 13px; 
    font-weight: 800; 
    text-transform: uppercase; 
}
.ff-items-table th:first-child { 
    border-radius: 6px 0 0 6px; 
    text-align: left; 
}
.ff-items-table th:last-child { 
    border-radius: 0 6px 6px 0; 
    text-align: right; 
}
.ff-items-table td { 
    padding: 12px 12px; 
    vertical-align: middle; 
    border-bottom: 1px solid rgba(228, 104, 19, 0.15); 
    font-size: 14px; 
}

.ff-service-select { 
    font-size: 12px; 
    font-weight: 700; 
    border: 1px solid #d0c0b0; 
    border-radius: 4px; 
    padding: 4px; 
    background: white; 
    margin-bottom: 4px; 
    width: 100%; 
    max-width: 320px; 
}
.ff-item-flex { 
    display: flex; 
    gap: 14px; 
    align-items: center; 
}

.ff-canva-badge {
    width: 54px;
    height: 54px;
    background-color: var(--badge-bg);
    border: 2px solid var(--badge-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(74, 46, 24, 0.08);
}
.ff-canva-badge img.ff-badge-svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.ff-item-title { 
    font-weight: 800; 
    font-size: 15px; 
}
.ff-item-desc { 
    font-size: 12px; 
    color: var(--text-muted); 
    line-height: 1.35; 
    margin-top: 3px; 
    white-space: normal; 
    word-break: break-word; 
}

/* Builder-only + Add Service Button below Line Items Table */
.ff-add-service-wrap {
    display: flex;
    justify-content: flex-start;
    margin-top: 10px;
    margin-bottom: 12px;
}
.ff-btn-add-service {
    background: #FFF8E7;
    border: 1.5px dashed #E46813;
    color: #E46813;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 13px;
    padding: 7px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.ff-btn-add-service:hover {
    background: #E46813;
    color: #fff;
    border-style: solid;
    box-shadow: 0 2px 6px rgba(228, 104, 19, 0.25);
}

.ff-totals-wrap { 
    display: flex; 
    justify-content: flex-end; 
    margin-top: 8px; 
}
.ff-totals-card { 
    width: 380px; 
}
.ff-totals-row { 
    display: flex; 
    justify-content: space-between; 
    padding: 4px 0; 
    font-size: 14px; 
    font-weight: 700; 
}
.ff-discount { 
    color: var(--danger-red); 
}
.ff-bold-row { 
    font-size: 15px; 
    font-weight: 800; 
    padding-top: 6px; 
    border-top: 1px solid var(--border-color); 
}
.ff-balance-banner { 
    background: var(--brand-orange); 
    color: white; 
    border-radius: 6px; 
    padding: 10px 16px; 
    margin-top: 12px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-size: 16px; 
    font-weight: 800; 
}

.ff-bottom-grid { 
    display: flex; 
    justify-content: space-around; 
    gap: 20px; 
    margin-top: 32px; 
    align-items: center; 
    border-top: 1px dashed var(--border-color); 
    padding-top: 20px; 
}
.ff-mascot-box { 
    text-align: center; 
}
.ff-mascot-img { 
    max-height: 120px; 
    object-fit: contain; 
    cursor: pointer; 
}
.ff-handwritten { 
    font-family: 'Caveat', cursive; 
    font-size: 21px; 
    color: var(--primary-brown); 
    margin-top: 6px; 
}
.ff-qr-box { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
}
.ff-qr-frame { 
    background: white; 
    padding: 8px; 
    border-radius: 12px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.06); 
    cursor: pointer; 
}
.ff-qr-frame img { 
    width: 100px; 
    height: 100px; 
    object-fit: contain; 
    display: block; 
}
.ff-upi-badge { 
    background: var(--brand-orange-light); 
    font-size: 12px; 
    font-weight: 700; 
    padding: 4px 12px; 
    border-radius: 10px; 
    margin-top: 8px; 
}

.ff-footer { 
    background: var(--brand-orange); 
    color: white; 
    display: flex; 
    justify-content: space-around; 
    align-items: center; 
    padding: 12px 20px; 
    font-size: 14px; 
    font-weight: 700; 
}
.ff-footer-item { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    color: #fff; 
}

[contenteditable="true"] { 
    outline: none; 
    border-radius: 2px; 
}
[contenteditable="true"]:hover { 
    background: rgba(228, 104, 19, 0.08); 
}
[contenteditable="true"]:focus { 
    background: rgba(228, 104, 19, 0.15); 
}
.ff-del-row { 
    cursor: pointer; 
    color: var(--danger-red); 
    font-weight: bold; 
    margin-left: 6px; 
}

/* Standalone preview bar styles */
.preview-bar { 
    width: 100%; 
    max-width: 800px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 14px; 
    color: #fff; 
}
.print-btn { 
    background: var(--brand-orange); 
    color: #fff; 
    border: none; 
    padding: 10px 20px; 
    border-radius: 6px; 
    font-size: 14px; 
    font-weight: 800; 
    cursor: pointer; 
}
.back-link { 
    color: #fff; 
    text-decoration: none; 
    font-weight: 700; 
    font-size: 14px; 
}

/* ==========================================================================
   Phase 6: Bottom Action Bar & A4 Fit Indicator
   ========================================================================== */
.ff-bottom-action-bar {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 12px 18px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    box-sizing: border-box;
}

.ff-a4-fit-status {
    font-size: 13px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s ease;
}
.ff-fit-ok {
    background: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #C8E6C9;
}
.ff-fit-warning {
    background: #FFF3CD;
    color: #856404;
    border: 1px solid #FFEEBA;
    font-weight: 800;
}

/* ==========================================================================
   Phase 6: Dedicated Frontend Staff Portal Application Shell
   ========================================================================== */
.ff-portal-wrapper {
    width: 100%;
    margin: 0 auto;
    font-family: 'Nunito', sans-serif;
}
.ff-portal-wrapper * {
    box-sizing: border-box;
}

/* Brand Lock Screen */
.ff-portal-lock-screen {
    max-width: 400px;
    margin: 40px auto;
    background: var(--bg-cream);
    border: 1px solid var(--border-color);
    padding: 36px 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(74, 46, 24, 0.08);
}
.ff-lock-brand .ff-lock-paw {
    font-size: 32px;
    display: block;
    margin-bottom: 4px;
}
.ff-lock-brand h2 {
    font-family: 'Fredoka', cursive;
    color: var(--primary-brown);
    margin: 4px 0 2px;
    font-size: 26px;
}
.ff-lock-sub {
    font-size: 14px;
    font-weight: 700;
    color: var(--brand-orange);
    margin-bottom: 12px;
}
.ff-lock-desc {
    font-size: 13.5px;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.4;
}
.ff-lock-error {
    background: #FFE6E6;
    color: var(--danger-red);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 14px;
    font-weight: 700;
}
.ff-lock-form input[type="password"] {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--badge-border);
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 15px;
    outline: none;
    background: #fff;
}
.ff-lock-form input[type="password"]:focus {
    border-color: var(--brand-orange);
    box-shadow: 0 0 0 2px rgba(228, 104, 19, 0.2);
}
.ff-lock-form button {
    width: 100%;
    padding: 12px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 15px;
    justify-content: center;
}

/* Compact Brand App Header */
.ff-portal-app-header {
    max-width: 800px;
    width: 100%;
    margin: 0 auto 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-cream);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(74, 46, 24, 0.04);
}
.ff-portal-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ff-portal-brand .ff-portal-paw {
    font-size: 20px;
}
.ff-portal-brand .ff-portal-title {
    font-family: 'Fredoka', cursive;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-brown);
}
.ff-portal-brand .ff-portal-tag {
    font-size: 11px;
    font-weight: 800;
    background: var(--brand-orange-light);
    color: var(--brand-orange);
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
}
.ff-portal-logout-btn {
    font-size: 13px;
    font-weight: 700;
    color: var(--danger-red);
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 4px;
    border: 1px solid rgba(197, 48, 48, 0.2);
    background: #fff;
    transition: all 0.2s;
}
.ff-portal-logout-btn:hover {
    background: #FFE6E6;
    border-color: var(--danger-red);
}

/* Minimize theme chrome strictly on authenticated portal (screen only) */
@media screen {
    body.ff-portal-authenticated .wp-block-post-title,
    body.ff-portal-authenticated .entry-title,
    body.ff-portal-authenticated .site-footer,
    body.ff-portal-authenticated footer.wp-block-template-part,
    body.ff-portal-authenticated .wp-site-blocks > footer {
        display: none !important;
    }
    body.ff-portal-page .entry-content {
        padding-top: 0 !important;
        padding-bottom: 20px !important;
    }
    body.ff-portal-page .wp-block-group.alignfull {
        padding-top: 10px !important;
        padding-bottom: 20px !important;
    }
}

/* ==========================================================================
   Phase 6: Responsive Mobile Card View & Fluid Scaling
   ========================================================================== */
@media screen and (max-width: 640px) {
    .ff-body {
        padding: 20px 14px 16px;
    }
    .ff-meta-grid {
        flex-direction: column;
        gap: 16px;
    }
    .ff-meta-col-left, .ff-meta-col-right {
        width: 100%;
    }
    .ff-items-table thead {
        display: none;
    }
    .ff-items-table, 
    .ff-items-table tbody, 
    .ff-items-table tr, 
    .ff-items-table td {
        display: block;
        width: 100%;
    }
    .ff-items-table tr {
        background: #fff;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 12px;
        margin-bottom: 12px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    }
    .ff-items-table td {
        padding: 4px 0;
        border-bottom: none;
    }
    .ff-totals-card {
        width: 100%;
    }
    .ff-bottom-grid {
        flex-direction: column;
        gap: 20px;
    }
    .ff-bottom-action-bar {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        background: rgba(250, 244, 235, 0.98);
        backdrop-filter: blur(8px);
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        flex-direction: column;
        align-items: stretch;
        padding: 10px 14px;
        margin-top: 10px;
    }
    .ff-bottom-action-bar .ff-btn-group {
        width: 100%;
        justify-content: stretch;
    }
    .ff-bottom-action-bar .ff-btn {
        flex: 1;
        justify-content: center;
    }
}
