/* Base Styles */
:root {
    --primary: #0056b3;
    --secondary: #f4f6f9;
    --text: #333;
    --bg: #fff;
    --border: #ddd;
    --font: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font);
    background-color: var(--secondary);
    color: var(--text);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: var(--primary);
}

/* Header & Navigation */
.site-header {
    background: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    padding: 15px 0;
    position: relative;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.logo span {
    color: var(--primary);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
}

.hamburger {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--text);
    position: relative;
    transition: all 0.3s;
}

.hamburger::before, .hamburger::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 3px;
    background: var(--text);
    left: 0;
    transition: all 0.3s;
}

.hamburger::before { top: -8px; }
.hamburger::after { top: 8px; }

/* Hamburger Animation */
.menu-toggle.active .hamburger { background: transparent; }
.menu-toggle.active .hamburger::before { top: 0; transform: rotate(45deg); }
.menu-toggle.active .hamburger::after { top: 0; transform: rotate(-45deg); }


.main-nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
}

.main-nav a {
    color: #555;
    font-weight: 500;
    transition: color 0.3s;
}

.main-nav a:hover {
    color: var(--primary);
}

/* Landing Page Headings */
.landing-header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary), #004494);
    color: #fff;
}

.landing-header h1 {
    font-size: 36px;
    margin-bottom: 10px;
}

.landing-header p {
    font-size: 18px;
    opacity: 0.9;
}

/* Generator Layout */
.generator-container {
    max-width: 1400px;
    margin: 30px auto;
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    padding: 0 20px;
}

.generator-controls {
    flex: 1;
    min-width: 300px;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.generator-preview {
    flex: 1.5;
    min-width: 300px;
}

.preview-sticky {
    position: sticky;
    top: 20px;
}

/* Form Controls */
.control-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.control-section h3 {
    margin-bottom: 15px;
    font-size: 18px;
    color: var(--primary);
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 5px;
}

.form-control {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.color-picker {
    padding: 0;
    height: 40px;
    cursor: pointer;
}

/* Item Rows */
.item-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.item-row .desc-input { flex: 3; }
.item-row .qty-input { flex: 1; min-width: 60px; }
.item-row .price-input { flex: 1; min-width: 80px; }

/* Buttons */
.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.3s;
}

.btn:hover { opacity: 0.9; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-success { background: #28a745; color: #fff; }
.btn-danger { background: #dc3545; color: #fff; padding: 10px; }
.btn-lg { font-size: 16px; padding: 12px 20px; width: 100%; margin-bottom: 10px; }

.mt-10 { margin-top: 10px; }

/* Live Preview Canvas */
.preview-canvas-wrapper {
    background: #e9ecef;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
}

.invoice-canvas {
    background: #fff;
    width: 210mm;
    min-height: 297mm;
    padding: 20mm;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin: 0 auto;
    position: relative;
    color: var(--text);
}

/* Dynamic CSS Variables injected via JS */
.invoice-canvas {
    font-family: var(--font);
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 3px solid var(--primary);
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.invoice-title {
    color: var(--primary);
    font-size: 32px;
    margin-bottom: 10px;
}

.invoice-meta {
    font-size: 14px;
}

.invoice-bill-to h4 {
    color: #555;
    margin-bottom: 5px;
}

.client-name {
    font-weight: bold;
    font-size: 18px;
}

.client-address {
    white-space: pre-wrap;
    margin-bottom: 30px;
}

/* Table styling for preview */
.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.invoice-table th {
    background-color: var(--primary);
    color: #fff;
    padding: 12px;
    text-align: left;
}

.invoice-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.text-center { text-align: center; }
.text-right { text-align: right; }

.invoice-summary {
    float: right;
    width: 50%;
    margin-bottom: 30px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 14px;
}

.grand-total {
    font-size: 18px;
    font-weight: bold;
    border-top: 2px solid var(--primary);
    padding-top: 10px;
    margin-top: 5px;
}

.invoice-words {
    clear: both;
    font-style: italic;
    color: #666;
    margin-bottom: 20px;
    padding: 10px;
    background: var(--secondary);
    border-left: 4px solid var(--primary);
}

.invoice-notes {
    font-size: 14px;
    white-space: pre-wrap;
}

/* Watermark & Logo */
.watermark-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.1;
    max-width: 80%;
    pointer-events: none;
}

.logo-img {
    max-width: 150px;
    max-height: 80px;
}

.logo-text {
    font-size: 24px;
    font-weight: bold;
    color: #ccc;
}

.hidden {
    display: none !important;
}

/* Template Switcher styles */
.traditional-template .invoice-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: 2px dashed var(--primary);
}
.traditional-template .invoice-title {
    font-size: 26px;
    letter-spacing: 2px;
}
.traditional-template .invoice-table th {
    background-color: transparent;
    color: var(--text);
    border-bottom: 2px solid var(--text);
}
.traditional-template .invoice-summary {
    width: 100%;
    margin-top: 20px;
}
.traditional-template .grand-total {
    border-top: 2px dashed var(--primary);
}

/* AdSense Containers */
.ad-slot {
    text-align: center;
    margin: 20px auto;
    padding: 10px;
    background: #f8f9fa;
    border: 1px dashed #ccc;
    max-width: 728px;
    min-height: 90px;
}

/* Content Pages */
.content-page {
    max-width: 800px;
    margin: 40px auto;
    padding: 30px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.content-page h1 { color: var(--primary); margin-bottom: 20px; }
.content-page h2 { margin: 25px 0 15px; color: #444; }
.content-page p { margin-bottom: 15px; }

/* Mobile Responsiveness */
.form-row { flex-direction: column; gap: 10px; }

@media (max-width: 768px) {
    .generator-container { flex-direction: column; }

    .menu-toggle {
        display: block;
    }

    .main-nav {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: #fff;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        display: none;
        padding: 20px 0;
    }

    .main-nav.open {
        display: block;
    }

    .main-nav ul {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .invoice-canvas {
        /* Mobile scale down for preview */
        transform: scale(0.6);
        transform-origin: top left;
        margin-bottom: -100px; /* Adjust height after scale */
    }
}

@media (min-width: 769px) {
    .form-row { flex-direction: row; gap: 15px; }
}

/* Print Rules for PDF/Image Export */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .generator-controls { display: none; }
    .generator-preview { width: 100%; margin: 0; padding: 0; }
    .preview-canvas-wrapper { padding: 0; background: transparent; overflow: visible; }
    .invoice-canvas { box-shadow: none; margin: 0; padding: 0; transform: none !important; }
}