/* Base Reset & Fonts */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

:root {
    --bg-dark: #0f0f13;
    --card-bg: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-color: #fdd835;
    /* Yellow */
    --accent-red: #e53935;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --glass-blur: blur(10px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Special Gothic', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

/* --- Button System (Phase 17) --- */
button,
.btn,
.action-btn,
.filter-btn,
.btn-save,
.btn-add,
.btn-refresh,
.btn-deliver,
.dash-card {
    font-family: 'Special Gothic', sans-serif !important;
}

.btn-base {
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-base:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.btn-base:active {
    transform: scale(0.98);
}

/* Primary (Yellow) */
.btn-primary {
    background: var(--accent-color);
    color: #000;
    box-shadow: 0 4px 15px rgba(253, 216, 53, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(253, 216, 53, 0.5);
}

/* Success (Green) */
.btn-success {
    background: #4caf50;
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.btn-success:hover {
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

/* Danger (Red) */
.btn-danger {
    background: var(--accent-red);
    color: white;
    box-shadow: 0 4px 15px rgba(229, 57, 53, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(229, 57, 53, 0.5);
}

/* Outline (Ghost) */
.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.btn-outline:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(253, 216, 53, 0.05);
}

/* --- Shared Components --- */
.home-link {
    position: absolute;
    top: 20px;
    left: 20px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: 0.3s;
    z-index: 10;
}

.home-link:hover {
    color: var(--accent-color);
}

/* --- A4 Form Styles (Phase 1 Exact Restoration) --- */
.a4-container {
    width: 210mm;
    min-height: 297mm;
    background: linear-gradient(135deg, #1a1a20 0%, #0f0f13 100%);
    padding: 40px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    position: relative;
    border: 1px solid var(--border-color);
}

/* Header */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.logo {
    height: 80px;
    filter: drop-shadow(0 0 10px rgba(253, 216, 53, 0.3));
}

.header-info h1 {
    font-family: 'Special Gothic', sans-serif;
    font-weight: 800;
    font-size: 24px;
    color: var(--accent-color);
    text-align: right;
    margin-bottom: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.meta-row {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.meta-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.meta-item label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.meta-item input {
    background: transparent !important;
    /* Force transparent for header */
    border: none !important;
    border-bottom: 1px solid transparent !important;
    color: var(--text-main);
    text-align: right;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    width: 120px;
    padding: 0;
    margin: 0;
    border-radius: 0;
}

.meta-item input:focus {
    border-bottom-color: var(--accent-color) !important;
    box-shadow: none !important;
}

/* Cards & Grid (Form) */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 12px;
    backdrop-filter: var(--glass-blur);
}

.card h2 {
    font-size: 14px;
    color: var(--accent-color);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Special Gothic', sans-serif;
    font-weight: 700;
}

.form-group {
    margin-bottom: 12px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

/* Main Inputs (Form) */
.a4-container input:not(.meta-item input),
.a4-container textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 10px;
    /* Phase 1 was 10px */
    border-radius: 6px;
    color: var(--text-main);
    font-family: 'Special Gothic', sans-serif;
    font-size: 14px;
    transition: 0.3s;
    margin-top: 0;
    /* Remove the generic margin that broke alignment */
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(253, 216, 53, 0.05);
}

.plate-input {
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
    border-color: var(--accent-color);
    font-family: 'Inter', sans-serif;
}

.delete-btn {
    background: #e53935;
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    transition: 0.2s;
    font-family: 'Special Gothic', sans-serif !important;
    position: relative;
    z-index: 100;
}

.delete-btn:hover {
    color: #ff5252;
    transform: scale(1.2);
}

/* Service Details */
.details-section .card {
    margin-bottom: 20px;
}

textarea {
    resize: none;
    line-height: 1.5;
}

/* Photos & Finance */
.bottom-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
    margin-bottom: 40px;
}

.photo-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.photo-box {
    aspect-ratio: 16/9;
    background: rgba(0, 0, 0, 0.3);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: 0.3s;
}

.photo-box:hover {
    border-color: var(--accent-color);
    background: rgba(253, 216, 53, 0.05);
}

.photo-box span {
    color: var(--text-muted);
    font-size: 12px;
}

.preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    position: absolute;
    left: 0;
    top: 0;
}

.preview.active {
    display: block;
}

/* Financials (Exact Phase 1) */
.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.calc-row label {
    margin: 0;
    font-size: 13px;
}

.calc-row input {
    width: 120px;
    text-align: right;
}

.total-row {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.total-row label,
.total-row input {
    color: var(--accent-color);
    font-weight: 800;
    font-size: 16px;
    font-family: 'Special Gothic', sans-serif;
}

.total-row input {
    border: none;
    background: transparent;
}

.payment-row {
    margin-top: 10px;
}

.payment-row input {
    border-color: var(--accent-red);
}

/* Footer */
.form-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 40px;
    display: flex;
    justify-content: space-between;
}

.signature-box {
    text-align: center;
    width: 200px;
}

.signature-box p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 40px;
}

.sign-line {
    border-bottom: 1px solid var(--text-muted);
}

.brand-footer {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 3px;
    opacity: 0.5;
}

/* FAB */
.fab-print {
    position: fixed;
    bottom: 30px;
    right: 30px;
    /* Utilizing btn-primary styles manually for fixed pos */
    background: var(--accent-color);
    color: #000;
    border: none;
    padding: 16px 32px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 16px;
    box-shadow: 0 4px 15px rgba(253, 216, 53, 0.4);
    cursor: pointer;
    transition: 0.3s;
    z-index: 100;
    font-family: 'Special Gothic', sans-serif;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.fab-print:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(253, 216, 53, 0.6);
}


/* --- Reports Page Styles (Phase 3 Integration) --- */
.report-container {
    width: 100%;
    max-width: 1000px;
    margin: 40px auto;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.report-header h1 {
    font-family: 'Special Gothic', sans-serif;
    font-weight: 800;
    font-size: 24px;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.filters {
    display: flex;
    gap: 10px;
}

.filter-btn {
    /* Inherits btn-base logic conceptually but kept specific for size */
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px 20px;
    border-radius: 50px;
    text-decoration: none;
    font-size: 13px;
    transition: 0.3s;
    font-weight: 500;
    font-family: 'Special Gothic', sans-serif;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
    font-weight: bold;
    box-shadow: 0 0 15px rgba(253, 216, 53, 0.4);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    backdrop-filter: var(--glass-blur);
    text-align: center;
    transition: 0.3s;
}

.stat-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-3px);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-val {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent-color);
    font-family: 'Inter', sans-serif;
}

/* Report Table */
.table-card {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.records-table {
    width: 100%;
    border-collapse: collapse;
}

.records-table th {
    text-align: left;
    color: var(--text-muted);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
}

.records-table td {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 15px;
}

.records-table tr:last-child td {
    border-bottom: none;
}

.records-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
}

.plate-badge {
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.3);
}

.price-col {
    color: var(--accent-color);
    font-weight: 800;
    font-family: 'Inter', sans-serif;
}

.action-icon {
    opacity: 0;
    transition: 0.3s;
    color: var(--accent-color);
}

.records-table tr:hover .action-icon {
    opacity: 1;
    transform: translateX(5px);
}


input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 10px rgba(253, 216, 53, 0.2);
}

/* --- Print Media Query --- */
@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body {
        margin: 0;
        padding: 0;
        background: white;
        color: black;
        width: 210mm;
        height: 297mm;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .home-link,
    .fab-print,
    .action-bar,
    .filters,
    .btn-save,
    .action-buttons,
    .photo-container,
    .photo-box,
    .bottom-grid {
        display: none !important;
    }

    .a4-container {
        width: 100%;
        min-height: 100%;
        box-shadow: none;
        border: none;
        background: white;
        padding: 5mm;
        /* Print padding */
        color: black;
        transform: scale(0.95);
        transform-origin: top left;
    }

    /* Force text colors for print */
    :root {
        --text-main: #000;
        --text-muted: #555;
        --accent-color: #000;
        --accent-red: #000;
        --border-color: #ccc;
    }

    input,
    textarea {
        background: transparent !important;
        border: none !important;
        border-bottom: 1px dotted #999 !important;
        color: black !important;
        padding: 2px 0 !important;
        border-radius: 0;
    }

    /* Remove card styles for print */
    .card {
        background: transparent;
        border: none;
        border-bottom: 1px solid #ddd;
        border-radius: 0;
        backdrop-filter: none;
        padding: 5px 0;
        margin-bottom: 10px;
    }

    h1,
    h2,
    label {
        color: black !important;
    }

    .logo {
        filter: none;
    }

    .photo-box {
        border: 1px solid #ccc;
        background: white;
    }

    .form-header {
        border-bottom: 2px solid black;
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    /* Compact spacing for print */
    .info-grid {
        gap: 10px;
        margin-bottom: 10px;
    }

    .bottom-grid {
        gap: 10px;
        margin-bottom: 20px;
    }

    .form-group {
        margin-bottom: 5px;
    }

    .form-footer {
        padding-top: 20px;
        margin-top: auto;
    }
}

/* --- Responsive Media Query --- */
@media (max-width: 800px) {
    body {
        padding: 10px;
        display: block;
    }

    /* A4 Form Mobile */
    .a4-container {
        width: 100%;
        min-height: auto;
        border: none;
        box-shadow: none;
    }

    .info-grid,
    .bottom-grid,
    .photo-container {
        grid-template-columns: 1fr;
    }

    .form-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .logo {
        height: 60px;
    }

    .meta-row {
        justify-content: flex-start;
    }

    /* Reports Mobile */
    .report-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 10px;
    }

    /* Table Mobile (Cards) */
    .records-table,
    .records-table tbody,
    .records-table tr,
    .records-table td {
        display: block;
        width: 100%;
    }

    .records-table thead {
        display: none;
    }

    .records-table tr {
        margin-bottom: 15px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 15px;
    }

    .records-table td {
        padding: 8px 0;
        border: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .records-table td:before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 12px;
    }

    .records-table td.plate-cell {
        font-weight: bold;
        font-size: 16px;
        margin-bottom: 10px;
    }

    .records-table td.plate-cell:before {
        display: none;
    }

    .action-icon {
        display: none;
    }

    /* Signature Input Styles */
    .signature-box p {
        font-size: 12px;
        color: var(--text-muted);
        margin-bottom: 15px;
    }

    .sign-input {
        border: none;
        border-bottom: 1px solid var(--text-muted);
        background: transparent;
        text-align: center;
        color: var(--text-main);
        width: 80%;
        font-family: 'Inter', sans-serif;
        font-size: 14px;
        padding-bottom: 5px;
        margin: 0 auto;
        display: block;
    }

    .sign-input:focus {
        border-bottom-color: var(--accent-color);
        outline: none;
    }
}