/* ABOUTME: Mobile-first responsive styles for the cashbook PWA */
/* ABOUTME: Clean, modern design optimized for iPhone usage */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8fafc;
    color: #334155;
    line-height: 1.6;
}

.app {
    max-width: 100%;
    min-height: 100vh;
    background: #ffffff;
}

/* Header */
.header {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    padding: 1rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.balance-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.balance-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

.balance-amount {
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 0.25rem;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 72px;
    z-index: 99;
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    background: #f8fafc;
}

.tab-btn:hover {
    background: #f1f5f9;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 1rem;
    min-height: calc(100vh - 160px);
}

.tab-content.active {
    display: block;
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filters select,
.filters input[type="text"] {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: white;
}

.date-range-custom {
    display: none;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.date-range-custom.visible {
    display: flex;
}

.date-range-custom input[type="date"] {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: white;
}

.filter-summary {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    background: #f1f5f9;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.filter-income {
    color: #059669;
}

.filter-expense {
    color: #dc2626;
}

.filter-net {
    color: #2563eb;
}

/* Form Styles */
.transaction-form {
    max-width: 100%;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 0.875rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.5rem;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #f1f5f9;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.import-label {
    display: block;
    cursor: pointer;
    text-align: center;
}

/* Transactions List */
.transactions-list {
    margin-top: 1rem;
}

.transaction-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.transaction-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.transaction-amount {
    font-size: 1.125rem;
    font-weight: bold;
}

.transaction-amount.income {
    color: #059669;
}

.transaction-amount.expense {
    color: #dc2626;
}

.transaction-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #64748b;
}

.transaction-detail {
    background: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.transaction-date {
    color: #9ca3af;
    font-size: 0.75rem;
}

.transaction-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.action-buttons {
    display: flex;
    gap: 0.25rem;
}

.btn-edit,
.btn-delete {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.btn-edit:hover {
    background: #f0f9ff;
}

.btn-delete:hover {
    background: #fef2f2;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.summary-card h3 {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-card .amount {
    font-size: 1.5rem;
    font-weight: bold;
}

.summary-card.income .amount {
    color: #059669;
}

.summary-card.expense .amount {
    color: #dc2626;
}

.summary-card.balance .amount {
    color: #2563eb;
}

/* Export Section */
.export-section {
    margin-bottom: 2rem;
}

/* Monthly Summary */
.monthly-summary h3 {
    margin-bottom: 1rem;
    color: #374151;
}

.month-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.month-item h4 {
    color: #374151;
    font-size: 0.875rem;
}

.month-stats {
    text-align: right;
    font-size: 0.875rem;
}

.month-income {
    color: #059669;
}

.month-expense {
    color: #dc2626;
}

.month-balance {
    color: #2563eb;
    font-weight: bold;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.empty-state p {
    font-size: 1rem;
    line-height: 1.5;
}

/* Responsive Design */
@media (min-width: 768px) {
    .app {
        max-width: 768px;
        margin: 0 auto;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    }

    .summary-cards {
        grid-template-columns: repeat(3, 1fr);
    }

    .filters {
        max-width: 600px;
    }

    .transaction-form {
        max-width: 500px;
        margin: 0 auto;
    }
}

/* iOS Safari specific styles */
@supports (-webkit-touch-callout: none) {
    .header {
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    .app {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #0f172a;
        color: #e2e8f0;
    }

    .app {
        background: #1e293b;
    }

    .tab-content {
        background: #1e293b;
    }

    .transaction-item,
    .summary-card,
    .month-item {
        background: #334155;
        border-color: #475569;
    }

    .form-group input,
    .form-group select,
    .filters select,
    .filters input[type="text"],
    .date-range-custom input[type="date"] {
        background: #334155;
        border-color: #475569;
        color: #e2e8f0;
    }

    .filter-summary {
        background: #334155;
    }

    .btn-secondary {
        background: #334155;
        color: #e2e8f0;
        border-color: #475569;
    }

    .transaction-detail {
        background: #475569;
    }
}
