/* ================================
   CSS RESET & BASE STYLES
   ================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1a1a2e;
    --primary-light: #16213e;
    --accent-color: #0f4c75;
    --accent-light: #3282b8;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ================================
   INTRO SCREEN
   ================================ */
.intro-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%);
    position: relative;
    padding: 2rem;
    opacity: 1;
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.intro-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(15, 76, 117, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(26, 26, 46, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

.intro-screen.fade-out {
    opacity: 0;
    transform: scale(0.98);
}

.intro-content {
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
    position: relative;
    z-index: 1;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.intro-badge {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out 0.1s both;
}

.intro-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 12vw, 5.5rem);
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 0.02em;
    line-height: 1;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.intro-subtitle {
    font-family: var(--font-primary);
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    font-weight: 300;
    color: var(--text-secondary);
    letter-spacing: 0.4em;
    text-transform: uppercase;
    margin-top: 0.5rem;
    animation: fadeInUp 0.8s ease-out 0.3s both;
}

.intro-divider {
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-light));
    margin: 2rem auto;
    border-radius: 2px;
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.intro-tagline {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    animation: fadeInUp 0.8s ease-out 0.5s both;
}

.intro-location {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease-out 0.6s both;
}

.intro-location svg {
    opacity: 0.7;
}

.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-lg), 0 0 0 0 rgba(26, 26, 46, 0.3);
    animation: fadeInUp 0.8s ease-out 0.7s both;
}

.primary-btn:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), 0 0 0 4px rgba(26, 26, 46, 0.1);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn svg {
    transition: transform var(--transition-normal);
}

.primary-btn:hover svg {
    transform: translateX(4px);
}

.intro-footer {
    position: absolute;
    bottom: 2rem;
    left: 0;
    right: 0;
    text-align: center;
    animation: fadeInUp 0.8s ease-out 0.8s both;
}

.intro-footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* ================================
   BILLING SCREEN
   ================================ */
.billing-screen {
    display: none;
    min-height: 100vh;
    background: var(--bg-secondary);
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
}

.billing-screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Header */
.billing-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.brand h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 0.01em;
}

.brand .address {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.invoice-type-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 4px;
    gap: 4px;
}

.type-btn {
    padding: 0.5rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.type-btn.active {
    background: var(--bg-primary);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.type-btn:hover:not(.active) {
    color: var(--text-primary);
}

/* Main Content */
.billing-main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Form Sections */
.form-section {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.section-title svg {
    color: var(--accent-color);
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group label .optional {
    font-weight: 400;
    color: var(--text-muted);
}

.form-group input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: all var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(15, 76, 117, 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* Items Table */
.items-table-container {
    overflow-x: auto;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.items-table th {
    text-align: left;
    padding: 0.75rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.items-table td {
    padding: 0.5rem;
    vertical-align: middle;
}

.items-table tbody tr {
    border-bottom: 1px solid var(--border-light);
}

.items-table tbody tr:last-child {
    border-bottom: none;
}

.items-table input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-primary);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: all var(--transition-fast);
}

.items-table input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(15, 76, 117, 0.1);
}

.items-table input[readonly] {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
}

.col-sno { min-width: 45px; text-align: center; }
.col-hsn { min-width: 80px; }
.col-desc { min-width: 140px; }
.col-colour { min-width: 80px; }
.col-size { min-width: 60px; }
.col-qty { min-width: 70px; }
.col-rate { min-width: 80px; }
.col-amount { min-width: 90px; }
.col-action { width: 36px; }

.remove-item-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.remove-item-btn:hover {
    background: #fef2f2;
    color: var(--danger-color);
}

.add-item-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    margin-top: 1rem;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.add-item-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Totals Section */
.totals-section {
    background: linear-gradient(135deg, var(--bg-primary) 0%, #fafbfc 100%);
}

.totals-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 640px) {
    .totals-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.totals-inputs {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.totals-summary {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.total-row:not(:last-child) {
    border-bottom: 1px solid var(--border-light);
}

.total-row.grand-total {
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 2px solid var(--primary-color);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.total-row.grand-total span:last-child {
    font-size: 1.25rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

@media (min-width: 640px) {
    .action-buttons {
        flex-direction: row;
        justify-content: flex-end;
        flex-wrap: wrap;
    }
}

.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.secondary-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.download-btn {
    padding: 0.875rem 1.75rem;
    background: var(--success-color);
    box-shadow: var(--shadow-md), 0 0 0 0 rgba(16, 185, 129, 0.3);
}

.download-btn:hover {
    background: #059669;
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(16, 185, 129, 0.15);
}

/* WhatsApp Button */
.whatsapp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    background: #25D366;
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md), 0 0 0 0 rgba(37, 211, 102, 0.3);
}

.whatsapp-btn:hover {
    background: #128C7E;
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(37, 211, 102, 0.2);
    transform: translateY(-2px);
}

.whatsapp-btn:active {
    transform: translateY(0);
}

.whatsapp-btn svg {
    width: 20px;
    height: 20px;
}

/* Footer */
.billing-footer {
    text-align: center;
    padding: 2rem 1.5rem;
    border-top: 1px solid var(--border-light);
    margin-top: 2rem;
}

.billing-footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ================================
   RESPONSIVE ADJUSTMENTS
   ================================ */
@media (max-width: 640px) {
    .intro-title {
        font-size: 2.75rem;
    }
    
    .intro-subtitle {
        font-size: 1rem;
        letter-spacing: 0.25em;
    }
    
    .billing-header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .brand h1 {
        font-size: 1.25rem;
    }
    
    .brand .address {
        font-size: 0.7rem;
        line-height: 1.4;
    }
    
    .billing-main {
        padding: 1rem;
    }
    
    .form-section {
        padding: 1.25rem;
    }
    
    .section-title {
        font-size: 0.875rem;
    }
    
    .items-table th,
    .items-table td {
        padding: 0.375rem 0.25rem;
    }
    
    .items-table input {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .col-sno { min-width: 35px; }
    .col-hsn { min-width: 65px; }
    .col-desc { min-width: 100px; }
    .col-colour { min-width: 60px; }
    .col-size { min-width: 45px; }
    .col-qty { min-width: 50px; }
    .col-rate { min-width: 60px; }
    .col-amount { min-width: 70px; }
}

/* Print Styles */
@media print {
    .billing-header,
    .action-buttons,
    .billing-footer,
    .add-item-btn,
    .remove-item-btn {
        display: none !important;
    }
    
    .form-section {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ================================
   UTILITY CLASSES
   ================================ */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
