/* ================= MODAL STYLES ================= */
.modal-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(15, 23, 42, 0.6); 
    backdrop-filter: blur(8px); 
    z-index: 2000; 
    display: none; 
    align-items: flex-end; 
    justify-content: center; 
    opacity: 0; 
    transition: opacity 0.3s ease; 
    padding: 0;
    overflow: hidden;
}

@media (min-width: 768px) { 
    .modal-overlay { 
        align-items: center; 
        padding: 2rem; 
    } 
}

.modal-overlay.show { 
    display: flex; 
    opacity: 1; 
}

.modal-content { 
    background: var(--bg-surface); 
    width: 100%; 
    max-width: 600px; 
    max-height: 85vh;
    display: flex; 
    flex-direction: column; 
    border-radius: var(--radius-xl) var(--radius-xl) 0 0; 
    transform: translateY(100%); 
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); 
    box-shadow: var(--shadow-modal);
    overflow: hidden;
}

@media (min-width: 768px) { 
    .modal-content { 
        border-radius: var(--radius-xl); 
        transform: scale(0.95) translateY(20px); 
        max-height: 90vh;
    } 
}

.modal-overlay.show .modal-content { 
    transform: translateY(0) scale(1); 
}

.modal-header { 
    padding: 1.25rem 1.5rem; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-shrink: 0;
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-title { 
    font-size: 1.15rem; 
    font-weight: 800; 
    color: var(--secondary); 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
}

.close-btn { 
    width: 32px; 
    height: 32px; 
    border-radius: 50%; 
    background: var(--bg-body); 
    border: none; 
    color: var(--text-muted); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    transition: 0.2s; 
}
.close-btn:hover { 
    background: var(--danger-light); 
    color: var(--danger); 
    transform: rotate(90deg); 
}

.modal-body { 
    padding: 1.5rem; 
    overflow-y: auto; 
    flex: 1; 
    -webkit-overflow-scrolling: touch; 
}

.modal-footer { 
    padding: 1.25rem 1.5rem; 
    border-top: 1px solid var(--border); 
    background: var(--bg-surface-hover); 
    display: flex; 
    justify-content: flex-end; 
    gap: 0.75rem; 
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

/* Confirm Modal */
.confirm-icon-big { 
    font-size: 3.5rem; 
    color: var(--danger); 
    margin-bottom: 1rem; 
    text-align: center; 
}
.confirm-title { 
    text-align: center; 
    font-size: 1.25rem; 
    font-weight: 800; 
    margin-bottom: 0.5rem; 
}
.confirm-msg { 
    text-align: center; 
    color: var(--text-muted); 
    margin-bottom: 1.5rem; 
}

/* Invoice Lines */
.invoice-lines { 
    background: var(--bg-body); 
    border-radius: var(--radius-md); 
    border: 1px solid var(--border); 
    overflow: hidden; 
    margin-bottom: 1rem; 
}
.invoice-row { 
    display: flex; 
    padding: 0.75rem 1rem; 
    border-bottom: 1px solid var(--border); 
    align-items: center; 
    gap: 0.5rem; 
}
.invoice-row:last-child { 
    border-bottom: none; 
}
.invoice-row.header { 
    background: var(--border); 
    font-weight: 700; 
    font-size: 0.75rem; 
    color: var(--text-muted); 
    text-transform: uppercase; 
}
.inv-col-name { 
    flex: 2; 
    min-width: 100px; 
    font-weight: 600; 
    font-size: 0.85rem; 
}
.inv-col-qty { 
    width: 70px; 
    text-align: center; 
}
.inv-col-price { 
    width: 100px; 
    text-align: right; 
}
.inv-col-total { 
    width: 110px; 
    text-align: right; 
    font-weight: 700; 
}
.inv-col-action { 
    width: 30px; 
    text-align: center; 
}

/* Date Filter Container */
.date-filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1rem;
    border: 1px solid var(--border);
}
.date-filter-left {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.date-filter-left .filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.date-filter-right {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.date-range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.date-range-inputs .form-control {
    flex: 1;
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
}
.date-range-inputs span {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.date-filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}
.date-filter-actions button {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.8rem;
}
@media (max-width: 600px) {
    .date-filter-container {
        flex-direction: column;
    }
}

/* Phone Link */
.phone-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.phone-link:hover {
    text-decoration: underline;
}

/* PDF Preview */
.modal-overlay.fullscreen .modal-content { 
    max-width: 1000px; 
    max-height: 95vh; 
    height: auto;
    border-radius: var(--radius-lg); 
}
.a4-preview { 
    background: white; 
    width: 100%; 
    max-width: 210mm; 
    min-height: 297mm; 
    margin: 0 auto; 
    box-shadow: 0 0 20px rgba(0,0,0,0.1); 
    padding: 40px; 
    color: black; 
    font-family: 'Times New Roman', serif; 
}
.pdf-header { 
    display: flex; 
    justify-content: space-between; 
    border-bottom: 2px solid #000; 
    padding-bottom: 20px; 
    margin-bottom: 30px; 
}
.pdf-logo-area {
    display: flex;
    align-items: center;
    gap: 20px;
}
.pdf-logo {
    width: 80px;
    height: 80px;
    background: #f0f0f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: var(--primary);
}
.pdf-company-info {
    font-size: 14px;
}
.pdf-table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 20px; 
}
.pdf-table th, .pdf-table td { 
    border: 1px solid #ddd; 
    padding: 10px; 
    text-align: left; 
    font-size: 14px; 
}
.pdf-table th { 
    background: #f5f5f5; 
}
.pdf-total-box { 
    margin-top: 20px; 
    width: 300px; 
    float: right; 
}
.pdf-total-row { 
    display: flex; 
    justify-content: space-between; 
    padding: 5px 0; 
    border-bottom: 1px solid #eee; 
    font-size: 14px; 
}
.pdf-total-row.grand { 
    font-weight: bold; 
    font-size: 18px; 
    border-bottom: none; 
    border-top: 2px solid #000; 
    padding-top: 10px; 
}