/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --income-color: #10b981;
    --expense-color: #ef4444;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 80px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 0;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.header h1 i {
    margin-right: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Export Dropdown */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-dropdown #exportBtn {
    position: relative;
    padding-right: 40px;
}

.export-dropdown #exportBtn .fa-chevron-down {
    position: absolute;
    right: 12px;
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.export-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
    animation: dropdownSlideIn 0.2s ease;
}

.export-dropdown .dropdown-menu.show {
    display: block;
}

.export-dropdown #exportBtn.active .fa-chevron-down {
    transform: rotate(180deg);
}

@keyframes dropdownSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--bg-color);
}

.dropdown-item i {
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.dropdown-item:hover i {
    color: var(--primary-color);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-income {
    background: var(--income-color);
    color: white;
}

.btn-income:hover {
    background: #059669;
}

.btn-expense {
    background: var(--expense-color);
    color: white;
}

.btn-expense:hover {
    background: #dc2626;
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-save {
    background: var(--primary-color);
    color: white;
}

.btn-save:hover {
    background: var(--primary-dark);
}

.btn-cancel {
    background: var(--card-bg);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.btn-cancel:hover {
    background: var(--bg-color);
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.summary-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.income-card .summary-icon {
    background: linear-gradient(135deg, var(--income-color), #059669);
}

.expense-card .summary-icon {
    background: linear-gradient(135deg, var(--expense-color), #dc2626);
}

.balance-card .summary-icon {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.summary-content h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-amount {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Entries Section */
.entries-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.filter-controls {
    display: flex;
    gap: 10px;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.entries-table-container {
    overflow-x: auto;
}

.entries-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.entries-table thead {
    background: var(--bg-color);
}

.entries-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.entries-table td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.entries-table tbody tr:hover {
    background: var(--bg-color);
}

.entry-type {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.entry-type.income {
    background: #d1fae5;
    color: var(--income-color);
}

.entry-type.expense {
    background: #fee2e2;
    color: var(--expense-color);
}

.entry-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.action-btn.edit {
    background: #fef3c7;
    color: #d97706;
}

.action-btn.edit:hover {
    background: #fde68a;
}

.action-btn.view {
    background: #dbeafe;
    color: #2563eb;
}

.action-btn.view:hover {
    background: #bfdbfe;
}

.action-btn.delete {
    background: #fee2e2;
    color: var(--expense-color);
}

.action-btn.delete:hover {
    background: #fecaca;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
    display: flex;
    flex-direction: column;
}

#incomeModal .modal-content {
    max-height: 90vh;
    height: auto;
    overflow: visible;
    display: flex;
    flex-direction: column;
}

#incomeModal .modal-body {
    overflow: visible;
    flex: 1;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

#incomeModal .modal-body {
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow: visible;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 24px;
    border-top: 1px solid var(--border-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

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

/* Items Section */
.items-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 2px solid var(--border-color);
}

#incomeModal .items-section {
    margin-top: 0;
    padding-top: 24px;
    border-top: 2px solid var(--border-color);
}

.items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.items-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.items-list {
    margin-bottom: 16px;
}

#incomeModal .items-list {
    margin-bottom: 16px;
    padding-right: 4px;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
    padding: 16px;
    background: var(--bg-color);
    border-radius: 8px;
    margin-bottom: 12px;
}

.item-row input {
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
}

.item-row input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.item-remove {
    background: var(--expense-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.item-remove:hover {
    background: #dc2626;
}

.items-total {
    text-align: right;
    padding: 16px;
    background: var(--bg-color);
    border-radius: 8px;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.items-total span {
    color: var(--income-color);
    font-weight: 700;
}

/* Invoice */
.invoice-content {
    max-width: 800px;
}

.invoice-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

#invoiceBody {
    padding: 40px;
    background: white;
}

.invoice-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.invoice-header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.invoice-shop-info {
    text-align: left;
    margin-bottom: 30px;
}

.invoice-shop-info p {
    margin: 5px 0;
    color: var(--text-secondary);
}

.invoice-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

.invoice-table th {
    background: var(--bg-color);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.invoice-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.invoice-table tfoot td {
    font-weight: 700;
    border-top: 2px solid var(--border-color);
    border-bottom: none;
}

.invoice-total {
    text-align: right;
    font-size: 1.25rem;
    color: var(--text-primary);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--income-color);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 2000;
    animation: toastSlideIn 0.3s ease;
}

.toast.show {
    display: flex;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
    margin-top: 40px;
}

.app-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.app-footer a:hover {
    text-decoration: underline;
}

.app-footer .footer-link {
    color: var(--primary-color);
}

.app-footer .footer-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.app-footer .bmc-logo {
    display: inline-block;
    margin-top: 1rem;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.app-footer .bmc-logo:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.app-footer .bmc-logo img {
    height: 60px;
    width: 217px;
}

.app-footer .view-all-apps-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 1rem auto 0 auto;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    width: fit-content;
}

.app-footer .view-all-apps-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    text-decoration: none;
}

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .item-row {
        grid-template-columns: 1fr;
    }

    .item-row input {
        width: 100%;
    }

    .entries-table {
        font-size: 0.875rem;
    }

    .entries-table th,
    .entries-table td {
        padding: 8px;
    }

    .invoice-details {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 10px;
    }
}

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

    body {
        background: white;
        margin: 0;
        padding: 0;
    }

    /* Hide everything except invoice */
    .container,
    .controls,
    .summary-cards,
    .entries-section,
    .header,
    .app-footer,
    .toast,
    #incomeModal,
    #expenseModal,
    #settingsModal {
        display: none !important;
    }

    /* Show only invoice modal */
    #invoiceModal {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: white;
        padding: 0;
        margin: 0;
        z-index: 9999;
        overflow: visible;
    }

    #invoiceModal .modal-content {
        box-shadow: none;
        max-width: 100%;
        width: 100%;
        height: auto;
        margin: 0;
        padding: 20px;
        border: none;
        border-radius: 0;
        overflow: visible;
    }

    #invoiceModal .modal-header {
        display: none !important;
    }

    #invoiceModal .invoice-actions,
    #invoiceModal .modal-close,
    #invoiceModal .modal-header {
        display: none !important;
    }

    #invoiceBody {
        padding: 0;
        margin: 0;
        page-break-inside: avoid;
    }

    /* Prevent page breaks inside invoice elements */
    .invoice-header,
    .invoice-details,
    .invoice-table {
        page-break-inside: avoid;
    }

    /* Ensure invoice fits on one page */
    @page {
        size: A4;
        margin: 15mm;
    }

    /* Hide any scrollbars */
    ::-webkit-scrollbar {
        display: none;
    }
}

