/* 
 * Living 360 Quotation System
 * Main Stylesheet
 */

/* General Styles */
:root {
    --primary-color: #4e73df;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --info-color: #36b9cc;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --light-color: #f8f9fc;
    --dark-color: #5a5c69;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 80px;
}
.quotation-preview .document-page h1:first-of-type,
.quotation-preview .document-page h2:first-of-type {
    margin-top: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.5;
}

.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 999;
    background: #fff;
    color: #333;
    transition: all 0.3s;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 20px;
    background: var(--primary-color);
    color: white;
    text-align: center;
}

.sidebar-logo {
    width: 50px;
    margin-bottom: 10px;
}

.sidebar-menu {
    padding: 20px 0;
}

.sidebar-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu ul li {
    padding: 10px 20px;
    position: relative;
}

.sidebar-menu ul li a {
    color: #333;
    text-decoration: none;
    display: block;
    transition: all 0.3s;
}

.sidebar-menu ul li a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.sidebar-menu ul li.active {
    background: var(--light-color);
    border-left: 4px solid var(--primary-color);
}

.sidebar-menu ul li.active a {
    color: var(--primary-color);
    font-weight: 600;
}

.sidebar-menu ul li:hover {
    background: var(--light-color);
}

/* Main Content Styles */
.main-content {
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition: all 0.3s;
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
}

.main-content.expanded {
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* Navbar Styles */
.navbar {
    padding: 15px 20px;
    position: sticky;
    top: 0;
    z-index: 998;
}

#sidebarCollapse {
    background: var(--primary-color);
    border: none;
}

/* Card Styles */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.card-header {
    background-color: white;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.border-left-primary {
    border-left: 4px solid var(--primary-color);
}

.border-left-success {
    border-left: 4px solid var(--success-color);
}

.border-left-info {
    border-left: 4px solid var(--info-color);
}

.border-left-warning {
    border-left: 4px solid var(--warning-color);
}

.border-left-danger {
    border-left: 4px solid var(--danger-color);
}

/* Button Styles */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #2e59d9;
    border-color: #2e59d9;
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
}

.btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-block {
    display: block;
    width: 100%;
}

/* Form Styles */
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(78, 115, 223, 0.25);
}

/* Table Styles */
.table th {
    font-weight: 600;
    background-color: var(--light-color);
}

/* Footer Styles */
.footer {
    margin-top: auto;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Sidebar overlay for mobile */
#sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(1px);
    z-index: 998;
    display: none;
}
 #sidebar-overlay.active { display: block; }

/* Responsive Styles */
@media (max-width: 768px) {
    .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        box-shadow: 0 0 0 rgba(0,0,0,0);
    }
    
    .sidebar.active {
        margin-left: 0;
        box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    }
    
    .main-content {
        width: 100%;
    }
    
    .main-content.active {
        width: calc(100% - var(--sidebar-width));
    }
    
    /* Make tables scroll horizontally on small screens */
    .table-responsive { overflow-x: auto; }
    
    /* Improve spacing on small screens */
    .card { margin-bottom: 16px; }
}

/* Quotation and Invoice Styles */
.quotation-header, .invoice-header {
    margin-bottom: 30px;
}

.quotation-info, .invoice-info {
    margin-bottom: 20px;
}

.quotation-items, .invoice-items {
    margin-bottom: 30px;
}

.quotation-total, .invoice-total {
    margin-top: 20px;
}

.quotation-footer, .invoice-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

/* Quotation Preview Container */
.quotation-preview {
    max-width: 900px;
    margin: 0 auto;
}

.quotation-preview .document-page {
    background: #ffffff;
    /* Safe areas: allow letterhead background image to occupy top/bottom */
    padding: var(--header-safe, 24px) 24px var(--footer-safe, 24px);
    border: 1px solid #eee;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin: 0 auto;
    width: 100%;
    max-width: 210mm; /* A4 width */
    min-height: 297mm; /* A4 height */
    position: relative;
}

/* When a full-page letterhead background is used */
.quotation-preview .document-page.has-bg-letterhead {
    background-repeat: no-repeat;
    background-position: top center;
    background-size: cover; /* fill the page area */
}

/* Letterhead block */
.quotation-preview .letterhead { 
    margin-bottom: 8px; 
}
.quotation-preview .letterhead-image img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}
.quotation-preview .letterhead-content {
    width: 100%;
    overflow: hidden;
}
.quotation-preview .letterhead-content img {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
}
.quotation-preview .letterhead-content * {
    max-width: 100% !important;
}
.quotation-preview .default-letterhead .company-logo img {
    max-height: 60px;
    width: auto;
}

/* Letterhead footer */
.quotation-preview .letterhead-footer {
    width: 100%;
}
.quotation-preview .letterhead-footer img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Ensure tables fit nicely */
.quotation-preview .table {
    width: 100%;
    margin-bottom: 0;
}
.quotation-preview .table td, 
.quotation-preview .table th { 
    vertical-align: middle; 
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .quotation-preview { max-width: 100%; }
    .quotation-preview .document-page { padding: 16px; min-height: auto; }
    .quotation-preview .letterhead-image img { max-height: 35mm; }
}

/* Print styles for A4 */
@media print {
    @page { size: A4; margin: 0; }
    body { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .sidebar, .navbar, .btn, .card-header, .breadcrumb, .btn-group, .container-fluid > .row:first-child { display: none !important; }
    .main-content, .container-fluid, .quotation-preview { width: 100% !important; margin: 0 !important; padding: 0 !important; }
    .quotation-preview .document-page {
        box-shadow: none;
        border: 0;
        width: auto;
        max-width: none;
        min-height: auto;
        /* Use safe areas if provided, else default to 12mm margins */
        padding: var(--header-safe, 12mm) 12mm var(--footer-safe, 12mm);
        page-break-after: always;
    }
    /* Constrain header height specifically for print */
    .quotation-preview .letterhead-image img { max-height: 45mm; }
    .quotation-preview .table { page-break-inside: auto; }
    .quotation-preview .table thead { display: table-header-group !important; }
    .quotation-preview .table tfoot { display: table-footer-group !important; }
    .quotation-preview tr { page-break-inside: avoid; page-break-after: auto; }
    .quotation-preview td, .quotation-preview th { page-break-inside: avoid; }
    .quotation-preview img { page-break-inside: avoid; }
    .quotation-preview .document-header, 
    .quotation-preview .document-footer, 
    .quotation-preview .notes, 
    .quotation-preview .terms { page-break-inside: avoid; }
    /* Utility class to force a new printed page */
    .page-break { break-after: page; page-break-after: always; }
}


/* Letterhead Editor Styles */
.letterhead-editor {
    border: 1px solid #ddd;
    padding: 20px;
    min-height: 300px;
    margin-bottom: 20px;
}

/* PDF Preview Styles */
.pdf-preview {
    border: 1px solid #ddd;
    padding: 20px;
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Flash Messages */
.flash-message {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
}

.flash-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.flash-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}