@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #4c63d2;
    --secondary-color: #f093fb;
    --accent-color: #4facfe;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-color: #1f2937;
    --light-color: #f8fafc;
    --white: #ffffff;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --border-radius: 0.75rem;
    --border-radius-sm: 0.5rem;
    --border-radius-lg: 1rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--dark-color);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Ccircle cx='7' cy='7' r='1'/%3E%3Ccircle cx='53' cy='53' r='1'/%3E%3Ccircle cx='30' cy='30' r='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-xl);
}

.header-left h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.25rem;
}

.header-subtitle {
    color: var(--gray-600);
    font-size: 0.9rem;
}

.back-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Filters Section */
.filters-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: end;
    box-shadow: var(--shadow-lg);
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
    font-size: 0.9rem;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.apply-filters-btn,
.reset-filters-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.apply-filters-btn {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
}

.apply-filters-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.reset-filters-btn {
    background: var(--gray-200);
    color: var(--gray-700);
}

.reset-filters-btn:hover {
    background: var(--gray-300);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    border-left: 4px solid;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.stat-customers {
    border-left-color: var(--info-color);
}

.stat-cash {
    border-left-color: var(--success-color);
}

.stat-card-payment {
    border-left-color: var(--accent-color);
}

.stat-credit {
    border-left-color: var(--danger-color);
}

.stat-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--gray-600);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark-color);
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
}

/* Bills Section */
.bills-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
}

.bills-section h2 {
    margin-bottom: 1.5rem;
    color: var(--dark-color);
    font-weight: 600;
    font-size: 1.5rem;
}

.table-container {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.bills-table {
    width: 100%;
    border-collapse: collapse;
}

.bills-table thead {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.bills-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
}

.bills-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.bill-row {
    transition: all 0.2s ease;
    cursor: pointer;
}

.bill-row:hover {
    background: var(--gray-100);
    transform: translateX(4px);
}

.bill-number {
    font-weight: 700;
    color: var(--primary-color);
}

.bill-datetime small {
    color: var(--gray-600);
    font-size: 0.8rem;
}

.text-danger {
    color: var(--danger-color);
    font-weight: 600;
}

.text-success {
    color: var(--success-color);
    font-weight: 600;
}

.no-data {
    text-align: center;
    padding: 3rem !important;
    color: var(--gray-600);
    font-style: italic;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-cash {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.badge-card {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info-color);
    border: 1px solid var(--info-color);
}

.badge-credit {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

/* Action Buttons */
.bill-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.action-btn {
    background: var(--white);
    border: 1px solid var(--gray-300);
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.action-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.action-dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 150px;
    z-index: 100;
    margin-top: 0.25rem;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--dark-color);
    text-decoration: none;
    transition: all 0.2s ease;
}

.dropdown-menu a:hover {
    background: var(--gray-100);
}

/* Preview Section */
.preview-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    display: flex;
    flex-direction: column;
}

.preview-section h2 {
    margin-bottom: 1.5rem;
    color: var(--dark-color);
    font-weight: 600;
    font-size: 1.5rem;
}

.preview-container {
    flex: 1;
    border: 2px dashed var(--gray-300);
    border-radius: var(--border-radius);
    padding: 1rem;
    overflow-y: auto;
    background: white;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gray-600);
    text-align: center;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.preview-actions {
    margin-top: 1.5rem;
}

.print-large-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.print-large-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Print Area */
.print-area {
    display: none;
}

@media print {
    body * {
        visibility: hidden;
    }
    
    .print-area, .print-area * {
        visibility: visible !important;
    }
    
    .print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .preview-section {
        position: static;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .filters-section {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
/* Payment Type Dropdown Styling */
.payment-type-select {
    padding: 6px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.payment-type-select:hover {
    border-color: #4CAF50;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

.payment-type-select:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.payment-type-select option {
    padding: 8px;
    font-weight: 600;
}
/* ===========================
   POPUP OVERLAY STYLES
   =========================== */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.popup-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(50px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-header h2 {
    margin: 0;
    font-size: 22px;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.popup-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.popup-body {
    padding: 30px;
}

.search-section {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.search-section h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.search-section input {
    width: calc(100% - 120px);
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    margin-right: 10px;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.search-section input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-search {
    padding: 12px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.btn-search:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.divider {
    text-align: center;
    margin: 25px 0;
    position: relative;
    color: #999;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 42%;
    height: 1px;
    background: #e0e0e0;
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.new-customer-section {
    background: #fff8f0;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.new-customer-section h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    margin-bottom: 6px;
    color: #555;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.form-group input,
.form-group textarea {
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-family: 'Noto Sans Sinhala', sans-serif;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.selected-customer {
    background: #e8f5e9;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 2px solid #4caf50;
}

.selected-customer h3 {
    margin: 0 0 15px 0;
    color: #2e7d32;
    font-size: 16px;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.customer-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
}

.customer-info p {
    margin: 8px 0;
    color: #333;
    font-size: 15px;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.customer-info strong {
    color: #555;
    margin-right: 10px;
}

.bill-summary {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 12px;
}

.bill-summary h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
}

.summary-table tr {
    border-bottom: 1px solid #e0e0e0;
}

.summary-table tr:last-child {
    border-bottom: none;
}

.summary-table td {
    padding: 10px 0;
    font-size: 15px;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.summary-table td:first-child {
    color: #666;
}

.summary-table td:last-child {
    text-align: right;
}

.highlight-row {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
}

.highlight-row td {
    padding: 12px 10px;
    font-size: 16px;
}

.popup-footer {
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.btn-cancel,
.btn-confirm {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Noto Sans Sinhala', sans-serif;
}

.btn-cancel {
    background: #f5f5f5;
    color: #666;
}

.btn-cancel:hover {
    background: #e0e0e0;
}

.btn-confirm {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.text-danger {
    color: #f44336;
    font-weight: 700;
}

.text-success {
    color: #4caf50;
    font-weight: 700;
}

/* Responsive Design */
@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .search-section input {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .popup-footer {
        flex-direction: column;
    }
    
    .btn-cancel,
    .btn-confirm {
        width: 100%;
    }
}
