/* ========================================
   iOS 18 Design System - Invoice Generator
   ======================================== */

/* CSS Variables - iOS 18 Color Palette */
:root {
    /* System Colors */
    --ios-blue: #007AFF;
    --ios-blue-dark: #0A84FF;
    --ios-teal: #5AC8FA;
    --ios-green: #34C759;
    --ios-yellow: #FFD60A;
    --ios-orange: #FF9F0A;
    --ios-red: #FF453A;
    --ios-pink: #FF375F;
    --ios-purple: #BF5AF2;

    /* Backgrounds */
    --bg-primary: #F2F2F7;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: rgba(255, 255, 255, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.85);

    /* Text Colors */
    --text-primary: #000000;
    --text-secondary: #3C3C43;
    --text-tertiary: #8E8E93;
    --text-quaternary: #C7C7CC;

    /* Borders */
    --border-color: rgba(0, 0, 0, 0.1);
    --border-color-light: rgba(0, 0, 0, 0.05);

    /* Shadows - iOS 18 Style */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Border Radius - iOS 18 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Typography */
    --font-system: 'Outfit', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-base: 15px;
    --font-size-lg: 17px;
    --font-size-xl: 20px;
    --font-size-2xl: 28px;
    --font-size-3xl: 34px;

    /* Transition */
    --transition-fast: 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ========================================
   Base Styles
   ======================================== */

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

body {
    font-family: var(--font-system);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--text-primary);
    background: linear-gradient(135deg, #E3F2FD 0%, #F3E5F5 100%);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Layout - 40-60 Split
   ======================================== */

.container {
    display: grid;
    grid-template-columns: 40% 60%;
    height: calc(100vh - 100px);
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    max-width: 1920px;
    margin: 0 auto;
}

/* ========================================
   Dialogs & Modals
   ======================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color-light);
}

.modal-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
}

.modal-list {
    list-style: none;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    flex: 1;
}

.modal-list li {
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color-light);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-list li:hover {
    background: var(--bg-primary);
    border-color: var(--ios-blue);
}

.history-item-info {
    flex: 1;
}

.history-item-date {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.history-item-name {
    font-weight: 500;
    color: var(--text-primary);
}

.history-item-total {
    font-weight: 600;
    color: var(--ios-blue);
}

.history-actions {
    display: flex;
    gap: 8px;
}

.btn-icon-sm {
    padding: 4px 8px;
    font-size: 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.6;
}

.btn-icon-sm:hover {
    opacity: 1;
    transform: scale(1.1);
}

.btn-icon-sm.delete {
    color: var(--ios-red);
}


/* ========================================
   Panels - iOS 18 Frosted Glass
   ======================================== */

.form-panel,
.preview-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: var(--spacing-lg);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.2) 100%);
    border-bottom: 1px solid var(--border-color-light);
    backdrop-filter: blur(20px);
}

.panel-header h2 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    letter-spacing: -0.5px;
}

.panel-header .subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 400;
}

/* ========================================
   Form Panel
   ======================================== */

.form-panel {
    overflow-y: auto;
}

.form-panel::-webkit-scrollbar {
    width: 6px;
}

.form-panel::-webkit-scrollbar-track {
    background: transparent;
}

.form-panel::-webkit-scrollbar-thumb {
    background: var(--text-quaternary);
    border-radius: 10px;
}

.form-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

#invoiceForm {
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* ========================================
   Form Sections
   ======================================== */

.form-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.form-section:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.3px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

/* ========================================
   Form Groups & Inputs - iOS 18 Style
   ======================================== */

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
    letter-spacing: -0.08px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-system);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    background: var(--bg-secondary);
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

/* ========================================
   Buttons - iOS 18 Style
   ======================================== */

button {
    font-family: var(--font-system);
    font-size: var(--font-size-base);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    letter-spacing: -0.2px;
}

.btn-primary {
    padding: 14px 24px;
    background: var(--ios-blue);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background: #0051D5;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    padding: 14px 24px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--text-tertiary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-add {
    padding: 10px 18px;
    background: var(--ios-green);
    color: white;
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.btn-add span {
    font-size: 20px;
    font-weight: 700;
}

.btn-add:hover {
    background: #30D158;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-remove {
    width: 36px;
    height: 36px;
    background: var(--ios-red);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 300;
    flex-shrink: 0;
    padding: 0;
}

.btn-remove:hover {
    background: #FF6961;
    transform: scale(1.1);
}

.btn-remove:active {
    transform: scale(0.95);
}

/* ========================================
   Line Items
   ======================================== */

.items-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.item-row {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-end;
    padding: var(--spacing-md);
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color-light);
}

.item-fields {
    flex: 1;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: var(--spacing-md);
}

/* ========================================
   Toggle Switches - iOS 18 Style
   ======================================== */

.toggle-group {
    margin-bottom: var(--spacing-md);
}

.toggle-group:last-child {
    margin-bottom: 0;
}

.toggle-header {
    margin-bottom: var(--spacing-sm);
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.toggle-checkbox {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 51px;
    height: 31px;
    background: var(--text-quaternary);
    border-radius: 31px;
    transition: background var(--transition-base);
    margin-right: var(--spacing-md);
    flex-shrink: 0;
}

.toggle-switch::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-base);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-checkbox:checked+.toggle-switch {
    background: var(--ios-blue);
}

.toggle-checkbox:checked+.toggle-switch::before {
    transform: translateX(20px);
}

.toggle-text {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--text-primary);
}

.toggle-content {
    max-height: 200px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    margin-top: var(--spacing-sm);
}

.toggle-content.hidden {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

/* ========================================
   Form Actions
   ======================================== */

.form-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.form-actions button {
    flex: 1;
}

/* ========================================
   Preview Panel
   ======================================== */

.preview-panel {
    overflow-y: auto;
}

.preview-panel::-webkit-scrollbar {
    width: 6px;
}

.preview-panel::-webkit-scrollbar-track {
    background: transparent;
}

.preview-panel::-webkit-scrollbar-thumb {
    background: var(--text-quaternary);
    border-radius: 10px;
}

.invoice-preview {
    padding: var(--spacing-lg);
    flex: 1;
}

.invoice-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-xl);
    min-height: 100%;
}

/* ========================================
   Invoice Header
   ======================================== */

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: var(--spacing-lg);
    border-bottom: 2px solid var(--ios-blue);
    margin-bottom: var(--spacing-lg);
}

.company-info {
    flex: 1;
}

.preview-company-name {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.5px;
}

.preview-company-address,
.preview-company-contact,
.preview-company-tax {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.invoice-title-section {
    text-align: right;
}

.invoice-title-section h1 {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--ios-blue);
    margin-bottom: var(--spacing-xs);
    letter-spacing: -1px;
}

.invoice-title-en {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    font-weight: 600;
    letter-spacing: 2px;
}

/* ========================================
   Invoice Info
   ======================================== */

.invoice-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.invoice-meta {
    background: var(--bg-primary);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
}

.meta-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-base);
}

.meta-row:last-child {
    margin-bottom: 0;
}

.meta-row .label {
    font-weight: 600;
    color: var(--text-secondary);
}

.meta-row .value {
    color: var(--text-primary);
    font-weight: 500;
}

.customer-info-preview {
    background: var(--bg-primary);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
}

.customer-info-preview h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.preview-customer-name {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.preview-customer-address,
.preview-customer-contact {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

/* ========================================
   Invoice Table
   ======================================== */

.invoice-table-container {
    margin-bottom: var(--spacing-xl);
    overflow-x: auto;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-base);
}

.invoice-table thead {
    background: linear-gradient(135deg, var(--ios-blue) 0%, var(--ios-teal) 100%);
    color: white;
}

.invoice-table th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    font-size: var(--font-size-sm);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.invoice-table th.col-no {
    width: 50px;
    text-align: center;
}

.invoice-table th.col-quantity,
.invoice-table th.col-price,
.invoice-table th.col-total {
    text-align: right;
}

.invoice-table tbody tr {
    border-bottom: 1px solid var(--border-color-light);
    transition: background var(--transition-fast);
}

.invoice-table tbody tr:hover {
    background: var(--bg-primary);
}

.invoice-table tbody td {
    padding: 14px 12px;
    color: var(--text-primary);
}

.invoice-table tbody td.col-no {
    text-align: center;
    color: var(--text-tertiary);
    font-weight: 500;
}

.invoice-table tbody td.col-quantity,
.invoice-table tbody td.col-price,
.invoice-table tbody td.col-total {
    text-align: right;
    font-weight: 500;
}

.invoice-table .empty-state td {
    text-align: center;
    color: var(--text-tertiary);
    padding: var(--spacing-xl);
    font-style: italic;
}

/* ========================================
   Invoice Totals
   ======================================== */

.invoice-totals {
    margin-left: auto;
    width: 350px;
    background: var(--bg-primary);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
}

.totals-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-base);
}

.totals-row:last-child {
    margin-bottom: 0;
}

.totals-row .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.totals-row .value {
    color: var(--text-primary);
    font-weight: 600;
}

.totals-row.discount-row .label,
.totals-row.discount-row .value {
    color: var(--ios-red);
}

.totals-row.tax-row .label {
    color: var(--text-secondary);
}

.totals-row.grand-total {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 2px solid var(--ios-blue);
}

.totals-row.grand-total .label {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.totals-row.grand-total .value {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--ios-blue);
}

.totals-row.hidden {
    display: none;
}

/* ========================================
   Invoice Notes & Footer
   ======================================== */

.invoice-notes {
    background: var(--bg-primary);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
}

.invoice-notes h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.invoice-notes .preview-notes {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.6;
}

.invoice-footer {
    text-align: center;
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border-color-light);
}

.invoice-footer p {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    font-style: italic;
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    body {
        background: white;
    }

    .app-container {
        display: block;
        padding: 0;
    }

    .form-panel {
        display: none;
    }

    .preview-panel {
        width: 100%;
        background: white;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    .panel-header {
        display: none;
    }

    .invoice-content {
        box-shadow: none;
    }
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 1400px) {
    .app-container {
        grid-template-columns: 45% 55%;
    }
}

@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
        min-height: 100vh;
    }

    .form-panel,
    .preview-panel {
        max-height: none;
    }
}

@media (max-width: 768px) {

    /* Mobile Container Layout - Stack vertically */
    .container {
        display: flex;
        flex-direction: column;
        height: auto;
        padding: var(--spacing-md);
        gap: var(--spacing-md);
    }

    .form-panel,
    .preview-panel {
        width: 100%;
        max-height: none;
        height: auto;
        min-height: auto;
    }

    /* Scale down preview to fit mobile screen */
    .preview-panel {
        overflow: hidden;
    }

    .invoice-preview {
        transform: scale(0.5);
        transform-origin: top left;
        width: 200%;
        margin-bottom: -50%;
    }

    .invoice-content {
        min-width: 600px;
    }

    .form-row,
    .item-fields {
        grid-template-columns: 1fr;
    }

    .invoice-info {
        grid-template-columns: 1fr;
    }

    .invoice-header {
        flex-direction: column;
    }

    .invoice-title-section,
    .invoice-title {
        text-align: left;
        margin-top: var(--spacing-md);
    }

    .invoice-totals {
        width: 100%;
    }

    /* Mobile Form Styling */
    .form-section {
        padding: var(--spacing-md);
    }

    .section-title {
        font-size: var(--font-size-base);
    }

    /* Mobile Buttons */
    .form-actions {
        flex-direction: column;
    }

    .form-actions button {
        width: 100%;
    }

    /* Mobile Item Row */
    .item-row {
        padding: var(--spacing-md);
    }

    .item-fields {
        gap: var(--spacing-sm);
    }

    /* Mobile Signatures */
    .invoice-signatures {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .signature-box {
        width: 100%;
    }

    /* Mobile Invoice Bottom Section */
    .invoice-bottom-section {
        grid-template-columns: 1fr;
    }

    /* Mobile Panel Header */
    .panel-header {
        padding: var(--spacing-md);
    }

    .panel-header .title {
        font-size: var(--font-size-lg);
    }
}

/* Extra Small Devices (phones in portrait) */
@media (max-width: 480px) {

    .container {
        padding: var(--spacing-sm);
    }

    .form-section {
        padding: var(--spacing-sm);
    }

    .invoice-content {
        padding: var(--spacing-sm);
    }

    .invoice-table th,
    .invoice-table td {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: var(--font-size-xs);
    }

    .btn-primary,
    .btn-secondary {
        padding: 12px 16px;
        font-size: var(--font-size-sm);
    }
}

/* ========================================
   SEO Content Section
   ======================================== */

.content-section {
    background: white;
    padding: 60px 20px;
    margin-top: 40px;
}

.content-container {
    max-width: 1000px;
    margin: 0 auto;
}

.content-container h2 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 24px;
    text-align: center;
}

.content-container h3 {
    font-size: 20px;
    color: var(--text-primary);
    margin-top: 32px;
    margin-bottom: 16px;
}

.content-container p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 16px;
}

.content-container ul {
    margin-bottom: 24px;
    padding-left: 24px;
}

.content-container li {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.6;
}

.faq-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-top: 40px;
}

@media (max-width: 768px) {
    .faq-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Site Footer
   ======================================== */

.site-footer {
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    padding: 40px 20px;
    margin-top: 0;
}

.footer-content {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-logo img {
    height: 32px;
}

.footer-logo span {
    font-weight: 600;
    color: var(--text-primary);
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--ios-blue);
}

.footer-copyright {
    text-align: center;
    margin-top: 32px;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ========================================
   Cookie Consent Banner
   ======================================== */

.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 20px;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.cookie-banner.show {
    transform: translateY(0);
}

.cookie-content {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.cookie-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #cbd5e1;
}

.cookie-content a {
    color: var(--ios-blue);
    text-decoration: none;
    font-weight: 500;
}

.cookie-content a:hover {
    text-decoration: underline;
}

.cookie-btn {
    background: var(--ios-blue);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.cookie-btn:hover {
    background: #0051D5;
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .cookie-content {
        flex-direction: column;
        text-align: center;
    }

    .cookie-btn {
        width: 100%;
    }
}

/* ========================================
   Resource Tags (SEO)
   ======================================== */
.resource-tag,
.resource-tag-static {
    padding: 8px 16px;
    background: #f1f5f9;
    color: #475569;
    border-radius: 20px;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid #e2e8f0;
    display: inline-block;
}

.resource-tag:hover {
    background: white;
    color: var(--ios-blue);
    border-color: var(--ios-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.1);
}

.resource-tag-static {
    cursor: default;
    opacity: 0.7;
}


/* Share Button */
.btn-share {
    background: rgba(255, 255, 255, 0.9);
    color: var(--ios-blue);
    border: 1px solid var(--ios-blue);
}

.btn-share:hover {
    background: var(--ios-blue);
    color: white;
}

/* Small Buttons */
.btn-sm {
    padding: 4px 12px;
    font-size: 13px;
    line-height: 1.5;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-outline {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: #64748b;
}

.btn-outline:hover {
    background: #f8fafc;
    color: var(--ios-blue);
    border-color: var(--ios-blue);
}

.section-header .action-buttons {
    display: flex;
    gap: 8px;
}

/* Modal Simple */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-list {
    list-style: none;
    padding: 0;
    margin: 15px 0;
    max-height: 300px;
    overflow-y: auto;
}

.modal-list li {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

/* ========================================
   Print Styles
   ======================================== */
@media print {

    /* Hide non-printable elements */
    .app-header,
    .intro-section,
    .form-panel,
    .panel-header,
    .template-selector-section,
    .content-section,
    .trust-section,
    .site-footer,
    .cookie-banner,
    .modal-overlay,
    .toast,
    button,
    .btn-share,
    .resource-tag,
    .resource-tag-static {
        display: none !important;
    }

    /* Reset Layout */
    body {
        background: white;
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    .container {
        display: block;
        height: auto;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    /* Invoice Content */
    .preview-panel {
        background: white;
        border: none;
        box-shadow: none;
        padding: 0;
        overflow: visible;
    }

    .invoice-preview {
        padding: 0;
        margin: 0;
    }

    .invoice-content {
        box-shadow: none;
        padding: 0;
        border: none;
        min-height: auto;
    }

    /* Ensure backgrounds print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Layout adjustments for print */
    .invoice-table th {
        color: white !important;
        /* Force white text on headers */
    }
}

/* ========================================
   Template Styles
   ======================================== */

/* Template 1: Modern (Default - iOS Style) */
[data-template="modern"] .invoice-content {
    font-family: var(--font-system);
}

/* Template 2: Classic */
[data-template="classic"] .invoice-content {
    font-family: 'Sarabun', sans-serif;
    border: 1px solid #000;
}

[data-template="classic"] .invoice-header {
    border-bottom: 2px solid #000;
}

[data-template="classic"] .invoice-table thead {
    background: #f0f0f0;
    color: #000;
    border-bottom: 2px solid #000;
}

[data-template="classic"] .invoice-table th {
    color: #000 !important;
    font-weight: bold;
}

[data-template="classic"] .invoice-title h2 {
    color: #000;
}

/* Template 3: Minimal */
[data-template="minimal"] .invoice-content {
    font-family: 'Inter', sans-serif;
    box-shadow: none;
    border: none;
}

[data-template="minimal"] .invoice-header {
    border-bottom: none;
}

[data-template="minimal"] .invoice-table thead {
    background: transparent;
    color: #000;
    border-bottom: 2px solid #333;
}

[data-template="minimal"] .invoice-table th {
    color: #000 !important;
    text-transform: uppercase;
    letter-spacing: 1px;
}

[data-template="minimal"] .invoice-title h2 {
    color: #333;
    font-weight: 300;
}

/* Template 4: Colorful (Modern Pro) */
[data-template="colorful"] .invoice-content {
    background: linear-gradient(to bottom right, #ffffff, #f0f9ff);
    border: 1px solid #bae6fd;
}

[data-template="colorful"] .invoice-header {
    border-bottom: 2px solid #8b5cf6;
}

[data-template="colorful"] .invoice-title h2 {
    color: #8b5cf6;
}

[data-template="colorful"] .invoice-table thead {
    background: linear-gradient(90deg, #8b5cf6, #ec4899);
}

/* Template 5: Corporate (Executive) */
[data-template="corporate"] .invoice-content {
    font-family: 'Times New Roman', Times, serif;
    border-top: 10px solid #1e293b;
}

[data-template="corporate"] .invoice-header {
    border-bottom: 1px solid #ccc;
}

[data-template="corporate"] .invoice-title h2 {
    color: #1e293b;
    text-transform: uppercase;
}

[data-template="corporate"] .invoice-table thead {
    background: #1e293b;
}