:root {
    --primary: #1e293b;
    --accent: #007b85; /* Professional Teal from logo */
    --accent-light: #e0f2f1;
    --text: #334155;
    --text-light: #64748b;
    --light-bg: #f8fafc;
    --border: #e2e8f0;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --gold: #f39204;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--light-bg);
    color: var(--text);
    display: flex;
    height: 100vh;
    overflow: auto; /* Changed from hidden for better stability */
}

/* Sidebar Form */
.sidebar {
    width: 450px;
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 2rem;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
}

.sidebar h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    color: var(--text-light);
}

.form-group input, 
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus, 
.form-group textarea:focus {
    border-color: var(--accent);
}

.service-block {
    background: #f1f5f9;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    position: relative;
}

.btn-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #ef4444;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.btn-add {
    width: 100%;
    padding: 0.75rem;
    background: #e2e8f0;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    color: #64748b;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 1rem;
}

.btn-add:hover {
    background: #f1f5f9;
}

.btn-generate {
    width: 100%;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.2s;
}

.btn-generate:hover {
    filter: brightness(1.2);
}

/* Preview Area */
.main-view {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 3rem;
    overflow-y: auto;
    background-color: #cbd5e1; /* Realistic desk surface */
}

/* The Paper Simulation */
#quote-preview {
    width: 210mm; /* A4 Width */
    min-height: 297mm; /* A4 Height */
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    padding: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Improved PDF Design v2 (DesignStudio Style) */
#quote-preview {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    position: relative;
    padding: 0;
    overflow: visible; /* Changed from hidden to ensure full content capture */
    font-family: 'Inter', sans-serif;
    color: #333;
}

/* Background Pattern */
.pattern-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
        -45deg,
        rgba(0, 123, 133, 0.02) 0,
        rgba(0, 123, 133, 0.02) 1px,
        transparent 1px,
        transparent 10px
    );
    pointer-events: none;
    z-index: 0;
}

/* Header v2 */
.doc-header-v2 {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 50px 60px 40px;
    position: relative;
    z-index: 1;
    border-bottom: 2px solid var(--accent);
}

.h-left { width: 70%; }
.h-center { 
    width: 30%; 
    font-size: 11px; 
    color: var(--text-light);
    line-height: 1.6;
    padding: 0 10px;
}
.h-right { 
    width: 25%; 
    text-align: right; 
}

.doc-logo {
    width: 150px !important;
    height: auto;
    margin-bottom: 5px;
    display: block;
}

.company-name {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    margin: 0;
    letter-spacing: -0.5px;
}

.company-slogan {
    font-size: 11px;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.main-title {
    font-size: 42px;
    font-weight: 900;
    color: var(--primary);
    margin: 0;
    line-height: 1;
    text-transform: uppercase;
    opacity: 0.3; /* Increased from 0.15 for visibility */
}

/* Quote Info */
.quote-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    padding: 20px 60px;
    position: relative;
    z-index: 1;
}

.info-block .label {
    font-size: 10px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 1px;
    margin-bottom: 15px;
}

.info-block h3 {
    margin: 0 0 8px;
    font-size: 18px;
    color: var(--primary);
}

.info-block p {
    margin: 0;
    font-size: 13px;
    color: var(--text-light);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 4px 0;
    border-bottom: 1px dotted var(--border);
}

/* Total Bar */
.total-due-bar {
    background: var(--primary);
    color: white;
    margin: 10px 0;
    padding: 10px 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
}

.total-due-bar span:first-child {
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.bar-total {
    font-size: 24px;
    font-weight: 800;
    color: var(--gold);
}

/* Table */
.table-container {
    padding: 20px 40px;
    position: relative;
    z-index: 1;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table th {
    background: transparent;
    border-bottom: 2px solid var(--accent);
    padding: 10px 5px;
    text-align: left;
    font-size: 11px;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.items-table td {
    padding: 10px 5px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    vertical-align: top;
}

.items-table tr:nth-child(even) {
    background: rgba(0, 123, 133, 0.05); /* Zebra stripping in brand color */
}

/* Footer v2 */
.doc-footer-v2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    padding: 10px 40px;
    position: relative;
    z-index: 1;
}

.terms-text {
    font-size: 11px;
    color: var(--text-light);
    line-height: 1.5;
    margin-top: 10px;
}

.summary-table {
    margin-bottom: 20px;
}

.sum-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.sum-row span:first-child {
    color: var(--text-light);
}

.total-row {
    border-bottom: none;
    font-weight: 800;
    font-size: 18px;
    color: var(--primary);
    background: var(--light-bg);
    padding: 15px 10px;
    margin-top: 5px;
}

.signature-area {
    text-align: right;
    margin-top: 20px;
}

.sig-line {
    width: 200px;
    height: 1px;
    background: var(--primary);
    margin-left: auto;
}

.sig-name {
    margin: 10px 0 0;
    font-weight: 700;
    color: var(--primary);
}

.sig-title {
    margin: 0;
    font-size: 11px;
    color: var(--text-light);
}

/* Bottom Bar */
.bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--primary);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dot {
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
}

/* Print Specifics */
@media print {
    body { background: white; height: auto; display: block; }
    .sidebar { display: none; }
    .main-view { padding: 0; background: none; }
    #quote-preview { box-shadow: none; width: 100%; border: none; }
}
