/**
 * Expense Manager Styles
 * Version: 2.0.4
 * Last Updated: 2024
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 30px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid #667eea;
}

h1 {
    color: #667eea;
    font-size: 2em;
}

h3 {
    color: #555;
    margin: 20px 0 15px 0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary {
    background: #667eea;
}

.btn-secondary {
    background: #6c757d;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    margin: 2px;
}

.btn-danger {
    background: #dc3545;
}

.btn-danger:hover {
    background: #c82333;
}

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

.card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.card h3 {
    color: white;
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 10px 0;
    opacity: 0.9;
}

.card .amount {
    font-size: 32px;
    font-weight: bold;
    margin: 10px 0;
}

.card small {
    opacity: 0.8;
    font-size: 13px;
}

.amount.success {
    color: #10b981;
}

.amount.warning {
    color: #f59e0b;
}

/* Filters */
.filters {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.filters form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.filters label {
    font-weight: 600;
    color: #555;
    margin-right: 5px;
}

.filters input,
.filters select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

/* Table */
.table-container {
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

thead tr:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

th.sortable {
    cursor: pointer !important;
    user-select: none;
    position: relative;
    transition: background 0.2s;
}

th.sortable:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

th.sortable::after {
    content: ' ⇅';
    opacity: 0.5;
    margin-left: 5px;
}

th.sortable.sort-asc::after {
    content: ' ↑';
    opacity: 1;
}

th.sortable.sort-desc::after {
    content: ' ↓';
    opacity: 1;
}

th.sortable::after {
    content: ' ⇅';
    opacity: 0.5;
}

th.sortable.sort-asc::after {
    content: ' ↑';
    opacity: 1;
}

th.sortable.sort-desc::after {
    content: ' ↓';
    opacity: 1;
}

td {
    padding: 15px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

tbody tr:hover {
    background: #f8f9fa;
}

td.amount {
    font-weight: 600;
    color: #667eea;
    font-size: 15px;
}

.notes {
    display: block;
    color: #777;
    font-size: 12px;
    margin-top: 5px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 5px 12px;
    background: #e9ecef;
    color: #495057;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.success {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

/* Forms */
.form-container {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 12px;
    max-width: 800px;
}

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

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #777;
    font-size: 12px;
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert.success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

/* Pagination Styles */
.pagination-container {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.pagination-container > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.pagination-container .page-btn {
    min-width: 36px;
    height: 36px;
    padding: 8px 12px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    transition: all 0.3s;
}

.pagination-container .page-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
}

.pagination-container .page-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
    font-weight: 600;
}

.pagination-container .page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-container .page-ellipsis {
    padding: 8px;
    color: #999;
    font-weight: bold;
}

#paginationInfo {
    color: #555;
    font-weight: 500;
}

#itemsPerPage {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

#itemsPerPage:focus {
    outline: none;
    border-color: #667eea;
}

/* Bulk Actions */
.bulk-actions {
    background: #fff3cd;
    border: 2px solid #ffc107;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
    align-items: center;
    gap: 20px;
}

.bulk-actions.active {
    display: flex;
}

.bulk-summary {
    flex: 1;
    display: flex;
    gap: 30px;
}

.bulk-summary-item {
    font-size: 14px;
}

.bulk-summary-item strong {
    font-size: 18px;
    color: #667eea;
    display: block;
}

input[type="checkbox"].select-expense {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Navigation Header */
.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
}

.nav-links {
    display: flex;
    gap: 15px;
    align-items: center;
}

.user-info {
    color: #555;
    font-size: 14px;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: none !important;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal-backdrop[style*="display: flex"],
.modal-backdrop[style*="display:flex"] {
    display: flex !important;
}

.modal {
    background: #fff;
    width: min(900px, 96vw);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
}

.modal header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    gap: 10px;
    flex-wrap: wrap;
}

.modal .content {
    padding: 16px;
    max-height: 70vh;
    overflow: auto;
}

.file-row {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
}

.file-row .name {
    flex: 1;
}

.btn-icon {
    padding: 6px 10px;
}

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

/* Columns Menu */
.columns-menu {
    margin-left: auto;
    position: relative;
}

.columns-menu .menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    display: none !important;
    z-index: 10;
    min-width: 150px;
}

.columns-menu.open .menu {
    display: block !important;
}

/* Icon Buttons */
.icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    display: inline-block;
    vertical-align: middle;
    margin: 0 4px;
    background: #eef2ff;
    position: relative;
}

.icon-btn.edit::after {
    content: '✏️';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.icon-btn.duplicate::after {
    content: '⎘';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.icon-btn.delete {
    background: #fee2e2;
}

.icon-btn.delete::after {
    content: '🗑️';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.actions-cell .icon-btn {
    cursor: pointer;
}

/* Invoice Manager Styles */
.view-toggle {
    display: flex;
    gap: 5px;
}

.view-toggle .btn {
    padding: 8px 16px;
}

.view-toggle .btn.active {
    background: #667eea;
    color: white;
    border-color: #5568d3;
}

.invoice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.invoice-card {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s;
    background: white;
    position: relative;
}

.invoice-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.invoice-card.selected {
    border-color: #667eea;
    background: #f0f4ff;
}

.invoice-card .card-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.invoice-card .card-header input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin-top: 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.invoice-card .file-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    word-break: break-word;
    flex: 1;
    line-height: 1.4;
}

.invoice-card .file-meta {
    color: #6b7280;
    font-size: 13px;
    line-height: 1.8;
}

.invoice-card .file-meta div {
    margin: 3px 0;
}

.invoice-card .file-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.invoice-card .file-actions .btn {
    flex: 1;
    text-align: center;
}

.invoice-list-table {
    margin-top: 20px;
}

.invoice-list-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

.invoice-list-table tbody tr:hover {
    background: #f8f9fa;
}

.invoice-list-table tbody tr.selected {
    background: #f0f4ff;
}

.invoice-selectbar {
    background: #fff3cd;
    border: 2px solid #ffc107;
    padding: 15px 20px;
    border-radius: 10px;
    display: none;
    align-items: center;
    gap: 20px;
    margin: 15px 0;
}

.invoice-selectbar.active {
    display: flex;
}

.invoice-selectbar .summary {
    flex: 1;
    display: flex;
    gap: 30px;
}

.invoice-selectbar .summary-item {
    font-size: 14px;
}

.invoice-selectbar .summary-item strong {
    font-size: 18px;
    color: #667eea;
    display: block;
}

/* Topbar for invoice manager */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 3px solid #667eea;
}

.topbar h1 {
    margin: 0;
    color: #667eea;
    font-size: 2em;
}

.topbar .actions {
    display: flex;
    gap: 10px;
}

/* Invoice filters toolbar */
.invoice-filters-toolbar {
    margin-bottom: 25px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .filters form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 10px 8px;
    }
    
    .pagination-container > div {
        flex-direction: column;
    }
    
    .pagination-container .page-btn {
        min-width: 32px;
        height: 32px;
        padding: 6px 10px;
        font-size: 12px;
    }
}
