/* ========== Variables ========== */
:root {
    /* צבעי עמינדב - מהלוגו */
    --primary-blue: #5BA4D4;
    --primary-blue-dark: #2B7BB9;
    --primary-purple: #9B6B9E;
    --primary-purple-dark: #7B4B7E;
    --accent: #5BA4D4;
    --accent-light: #E8F4FC;
    
    /* צבעי סטטוס */
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #E53935;
    
    /* צבעי רקע וטקסט */
    --bg: #FFFFFF;
    --bg-light: #F8FAFC;
    --card: #FFFFFF;
    --text: #2C3E50;
    --text-light: #7F8C8D;
    --border: #E0E6ED;
    
    /* אפקטים */
    --shadow: 0 2px 12px rgba(91, 164, 212, 0.08);
    --shadow-lg: 0 8px 32px rgba(91, 164, 212, 0.12);
    --gradient-header: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-purple) 100%);
    --radius: 16px;
    --radius-sm: 10px;
}

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

body {
    font-family: 'Heebo', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ========== Header ========== */
.header {
    background: var(--bg);
    color: var(--text);
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.header-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.header-text {
    flex: 1;
}

.header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    background: var(--gradient-header);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2px;
}

.header-subtitle {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 400;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-light);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--primary-purple-dark);
    font-weight: 500;
    border: 1px solid var(--border);
}

/* ========== Main Content ========== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ========== Total Summary ========== */
.total-summary {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.total-summary-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

.total-summary-progress {
    /* Same as budget card progress */
}

/* ========== Expenses Summary Box ========== */
.expenses-summary-box {
    background: linear-gradient(135deg, var(--bg-light) 0%, #F3E8F4 100%);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

/* ========== Section Title ========== */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title svg {
    width: 20px;
    height: 20px;
    color: var(--primary-blue);
}

/* ========== Budget Cards ========== */
.budget-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.budget-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.budget-card:hover {
    box-shadow: var(--shadow-lg);
}

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

.budget-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

/* ========== Pending Badge ========== */
.pending-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, var(--accent-light), #F3E8F4);
    color: var(--primary-purple-dark);
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}
.budget-progress-container {
    margin-bottom: 12px;
}

.budget-progress-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.budget-progress-label {
    display: flex;
    flex-direction: column;
}

.budget-progress-label.start { align-items: flex-start; }
.budget-progress-label.center { align-items: center; }
.budget-progress-label.end { align-items: flex-end; }

.budget-progress-label-title {
    color: var(--text-light);
    font-size: 0.7rem;
}

.budget-progress-label-value {
    font-weight: 600;
    font-size: 0.85rem;
}

.budget-progress-label-value.blue { color: var(--primary-blue-dark); }
.budget-progress-label-value.orange { color: var(--warning); }
.budget-progress-label-value.green { color: var(--success); }

.progress-bar {
    height: 10px;
    background: var(--bg-light);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease;
}

.progress-fill.safe { 
    background: linear-gradient(90deg, var(--primary-blue), var(--primary-blue-dark)); 
}
.progress-fill.warning { 
    background: linear-gradient(90deg, var(--warning), #FFB74D); 
}
.progress-fill.danger { 
    background: linear-gradient(90deg, var(--danger), #EF5350); 
}

/* ========== Budget Progress with Labels ========== */
.budget-actions {
    display: flex;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.btn-budget {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-budget svg {
    width: 18px;
    height: 18px;
}

.btn-budget.primary {
    background: var(--gradient-header);
    color: white;
}

.btn-budget.primary:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.btn-budget.secondary {
    background: var(--bg-light);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-budget.secondary:hover {
    background: var(--accent-light);
    border-color: var(--primary-blue);
    color: var(--primary-blue-dark);
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card);
    border-radius: var(--radius);
    z-index: 201;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: translateY(0);
    opacity: 1;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--card);
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-light);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-light);
}

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

.modal-body {
    padding: 24px;
}

/* ========== Form ========== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
    background: var(--bg-light);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    background: white;
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input::placeholder {
    color: var(--text-light);
}

/* ========== Budget Info in Modal ========== */
.budget-info {
    background: linear-gradient(135deg, var(--accent-light), #F3E8F4);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 24px;
}

.budget-info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.budget-info-row:last-child {
    margin-bottom: 0;
    padding-top: 8px;
    border-top: 1px solid rgba(91, 164, 212, 0.2);
    font-weight: 600;
}

.budget-info-label {
    color: var(--text-light);
}

/* ========== Amount Feedback ========== */
.amount-feedback {
    margin-top: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: none;
}

.amount-feedback.show { 
    display: block; 
}
.amount-feedback.success {
    background: #E8F5E9;
    color: #2E7D32;
}
.amount-feedback.error {
    background: #FFEBEE;
    color: #C62828;
}

/* ========== File Upload ========== */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-light);
}

.file-upload:hover {
    border-color: var(--primary-blue);
    background: var(--accent-light);
}

.file-upload.has-file {
    border-color: var(--success);
    background: #E8F5E9;
}

.file-upload svg {
    width: 40px;
    height: 40px;
    color: var(--primary-blue);
    margin-bottom: 8px;
}

.file-upload.has-file svg {
    color: var(--success);
}

.file-upload-text {
    font-size: 0.9rem;
    color: var(--text-light);
}

.file-upload.has-file .file-upload-text {
    color: var(--success);
    font-weight: 500;
}

.file-input {
    display: none;
}

/* ========== Submit Button ========== */
.btn-submit {
    width: 100%;
    padding: 16px;
    background: var(--gradient-header);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-submit:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

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

.btn-submit:disabled {
    background: var(--border);
    cursor: not-allowed;
    transform: none;
}

.btn-submit svg {
    width: 20px;
    height: 20px;
}

/* ========== History Section ========== */
.history-section {
    margin-top: 32px;
}

/* ========== Data Table ========== */
.data-table-container {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-light);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-light);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background: var(--bg-light);
}

.data-table .amount {
    font-weight: 600;
    color: var(--primary-blue-dark);
}

.data-table .date {
    color: var(--text-light);
    font-size: 0.85rem;
}

.data-table .supplier {
    font-weight: 500;
}

.data-table .budget-name-cell {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ========== Expenses Modal ========== */
.expenses-summary-box {
    background: linear-gradient(135deg, var(--bg-light) 0%, #F3E8F4 100%);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

/* ========== Expense Cards (for mobile-friendly display) ========== */
.expense-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.expense-card {
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    padding: 14px;
    border: 1px solid var(--border);
}

.expense-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.expense-card-supplier {
    font-weight: 600;
    color: var(--text);
}

.expense-card-amount {
    font-weight: 700;
    color: var(--primary-blue-dark);
    font-size: 1.1rem;
}

.expense-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expense-card-date {
    font-size: 0.85rem;
    color: var(--text-light);
}

.no-expenses {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.no-expenses svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ========== Status Badge ========== */
.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-block;
    white-space: nowrap;
}

.status-pending {
    background: linear-gradient(135deg, var(--accent-light), #F3E8F4);
    color: var(--primary-purple-dark);
}

.status-approved {
    background: #E8F5E9;
    color: #2E7D32;
}

.status-rejected {
    background: #FFEBEE;
    color: #C62828;
}

.status-paid {
    background: #E3F2FD;
    color: #1565C0;
}

/* ========== Loading State ========== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-blue);
    border-right-color: var(--primary-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
    color: var(--primary-blue);
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    z-index: 300;
    opacity: 0;
    transition: all 0.3s ease;
    text-align: center;
    max-width: 400px;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success { 
    background: var(--success); 
}
.toast.error { 
    background: var(--danger); 
}

/* ========== Responsive ========== */
@media (max-width: 600px) {
    .container {
        padding: 16px;
    }

    .header-content {
        flex-wrap: wrap;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .user-badge {
        width: 100%;
        justify-content: center;
        margin-top: 12px;
    }

    .budget-card {
        padding: 16px;
    }

    .budget-header {
        flex-direction: column;
        gap: 8px;
    }

    .budget-code {
        align-self: flex-start;
    }

    .budget-progress-labels {
        gap: 4px;
    }

    .budget-progress-label-value {
        font-size: 0.8rem;
    }

    .budget-actions {
        flex-direction: column;
        gap: 8px;
    }

    .btn-budget {
        padding: 14px;
    }

    .modal {
        max-width: 100%;
        margin: 10px;
        max-height: calc(100vh - 20px);
        border-radius: var(--radius);
    }

    .modal-body {
        padding: 16px;
    }

    /* Invoice table on mobile - use cards instead */
    .data-table-container {
        display: none;
    }

    .invoice-cards-mobile {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .invoice-card-mobile {
        background: var(--bg-light);
        border-radius: var(--radius-sm);
        padding: 14px;
        border: 1px solid var(--border);
    }

    .invoice-card-mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 8px;
    }

    .invoice-card-mobile-supplier {
        font-weight: 600;
        color: var(--text);
    }

    .invoice-card-mobile-amount {
        font-weight: 700;
        color: var(--primary-blue-dark);
    }

    .invoice-card-mobile-details {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    .invoice-card-mobile-meta {
        font-size: 0.8rem;
        color: var(--text-light);
    }

    .invoice-card-mobile-budget {
        font-size: 0.8rem;
        color: var(--text-light);
        background: var(--card);
        padding: 2px 8px;
        border-radius: 4px;
    }
}

@media (min-width: 601px) {
    .invoice-cards-mobile {
        display: none;
    }
}