/**
 * Utility Classes for Immer Budget App
 * Replace inline styles with these semantic classes
 */

/* ========================================
   LAYOUT UTILITIES
   ======================================== */

/* Flexbox */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-auto { flex: auto; }
.flex-none { flex: none; }

/* Alignment */
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }

.self-start { align-self: flex-start; }
.self-center { align-self: center; }
.self-end { align-self: flex-end; }

/* Gap */
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }

/* Grid */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ========================================
   SPACING UTILITIES
   ======================================== */

/* Margin */
.m-0 { margin: 0; }
.m-1 { margin: 4px; }
.m-2 { margin: 8px; }
.m-3 { margin: 12px; }
.m-4 { margin: 16px; }
.m-5 { margin: 20px; }
.m-auto { margin: auto; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }

.ml-0 { margin-left: 0; }
.ml-1 { margin-left: 4px; }
.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 12px; }
.ml-4 { margin-left: 16px; }
.ml-auto { margin-left: auto; }

.mr-0 { margin-right: 0; }
.mr-1 { margin-right: 4px; }
.mr-2 { margin-right: 8px; }
.mr-3 { margin-right: 12px; }
.mr-4 { margin-right: 16px; }
.mr-auto { margin-right: auto; }

/* Padding */
.p-0 { padding: 0; }
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 20px; }
.p-6 { padding: 24px; }

.pt-0 { padding-top: 0; }
.pt-2 { padding-top: 8px; }
.pt-4 { padding-top: 16px; }

.pb-0 { padding-bottom: 0; }
.pb-2 { padding-bottom: 8px; }
.pb-4 { padding-bottom: 16px; }

.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }

.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }

/* ========================================
   TYPOGRAPHY UTILITIES
   ======================================== */

/* Font Size */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }

/* Font Weight */
.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Text Colors */
.text-primary { color: var(--primary); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray); }
.text-white { color: #fff; }

/* ========================================
   BACKGROUND UTILITIES
   ======================================== */

.bg-primary { background-color: var(--primary); }
.bg-success { background-color: var(--success); }
.bg-danger { background-color: var(--danger); }
.bg-warning { background-color: var(--warning); }
.bg-card { background-color: var(--bg-card); }
.bg-elevated { background-color: var(--bg-elevated); }
.bg-transparent { background-color: transparent; }

/* ========================================
   BORDER UTILITIES
   ======================================== */

.border { border: 1px solid var(--border); }
.border-0 { border: none; }
.border-t { border-top: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border-l { border-left: 1px solid var(--border); }
.border-r { border-right: 1px solid var(--border); }

.rounded { border-radius: 4px; }
.rounded-md { border-radius: 8px; }
.rounded-lg { border-radius: 12px; }
.rounded-xl { border-radius: 16px; }
.rounded-full { border-radius: 9999px; }

/* ========================================
   SIZE UTILITIES
   ======================================== */

.w-full { width: 100%; }
.w-auto { width: auto; }
.w-1\/2 { width: 50%; }
.w-1\/3 { width: 33.333%; }
.w-2\/3 { width: 66.666%; }

.h-full { height: 100%; }
.h-auto { height: auto; }
.min-h-screen { min-height: 100vh; }

/* ========================================
   DISPLAY UTILITIES
   ======================================== */

.hidden { display: none; }
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }

/* ========================================
   POSITION UTILITIES
   ======================================== */

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

/* ========================================
   OVERFLOW UTILITIES
   ======================================== */

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* ========================================
   CURSOR UTILITIES
   ======================================== */

.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }

/* ========================================
   SHADOW UTILITIES
   ======================================== */

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-none { box-shadow: none; }

/* ========================================
   TRANSITION UTILITIES
   ======================================== */

.transition { transition: all 0.2s ease; }
.transition-colors { transition: color 0.2s ease, background-color 0.2s ease; }
.transition-transform { transition: transform 0.2s ease; }

/* ========================================
   OPACITY UTILITIES
   ======================================== */

.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* ========================================
   COMPONENT CLASSES
   ======================================== */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-light);
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover {
    background: var(--success-light);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: var(--danger-light);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn-outline:hover {
    background: var(--bg-elevated);
}

.btn-sm {
    padding: 4px 12px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

/* Input */
.input {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.2s ease;
}

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

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    font-weight: 600;
    background: var(--bg-elevated);
}

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

/* ========================================
   BUDGET HEALTH - MINIMALIST REDESIGN
   ======================================== */

/* Compact Summary Bar */
.budget-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.budget-summary-bar__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.budget-summary-bar__stats {
    display: flex;
    align-items: center;
    gap: 24px;
    font-size: 0.875rem;
}

.budget-summary-bar__stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.budget-summary-bar__label {
    color: var(--text-secondary);
}

.budget-summary-bar__value {
    font-weight: 600;
    color: var(--text-primary);
}

.budget-summary-bar__value--success {
    color: var(--success);
}

.budget-summary-bar__value--danger {
    color: var(--danger);
}

/* Category List */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.category-list__item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-card);
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--border);
}

.category-list__item:last-of-type {
    border-bottom: none;
}

.category-list__item:hover {
    background: var(--bg-elevated);
}

.category-list__item--over {
    background: rgba(239, 68, 68, 0.03);
}

.category-list__item--over:hover {
    background: rgba(239, 68, 68, 0.06);
}

.category-list__name {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    min-width: 140px;
}

.category-list__progress {
    flex: 1;
    margin: 0 24px;
    max-width: 300px;
}

.category-list__progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.category-list__progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.category-list__progress-fill--success {
    background: var(--success);
}

.category-list__progress-fill--danger {
    background: var(--danger);
}

.category-list__progress-fill--warning {
    background: var(--warning);
}

.category-list__amounts {
    display: flex;
    align-items: baseline;
    gap: 4px;
    min-width: 140px;
    justify-content: flex-end;
}

.category-list__spent {
    font-size: 0.9375rem;
    font-weight: 600;
}

.category-list__spent--success {
    color: var(--text-primary);
}

.category-list__spent--danger {
    color: var(--danger);
}

.category-list__spent--warning {
    color: var(--warning);
}

.category-list__budget {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.category-list__expand {
    margin-left: 16px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.category-list__item--expanded .category-list__expand {
    transform: rotate(180deg);
}

/* Transactions within expanded category */
.category-transactions {
    display: none;
    padding: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
}

.category-transactions--visible {
    max-height: 2000px !important;
    overflow: visible !important;
    display: block;
}

/* Transaction Row */
.txn-row {
    display: flex;
    align-items: center;
    padding: 12px 20px 12px 40px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s ease;
}

.txn-row:hover {
    background: var(--bg-card);
}

.txn-row:last-child {
    border-bottom: none;
}

.txn-row__date {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    min-width: 60px;
}

.txn-row__details {
    flex: 1;
    margin-left: 16px;
}

.txn-row__store {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.txn-row__description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.txn-row__amount {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Transaction Card Modal */
.txn-card-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.txn-card-overlay--visible {
    opacity: 1;
    visibility: visible;
}

.txn-card {
    background: var(--bg-card);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(20px);
    transition: transform 0.2s ease;
}

.txn-card-overlay--visible .txn-card {
    transform: translateY(0);
}

.txn-card__header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.txn-card__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.txn-card__subtitle {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.txn-card__body {
    padding: 24px;
}

.txn-card__section {
    margin-bottom: 24px;
}

.txn-card__section:last-child {
    margin-bottom: 0;
}

.txn-card__section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.txn-card__info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.txn-card__info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.txn-card__info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.txn-card__info-value {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
}

.txn-card__info-value--large {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Editable Fields */
.txn-card__field {
    margin-bottom: 16px;
}

.txn-card__field:last-child {
    margin-bottom: 0;
}

.txn-card__label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.txn-card__input {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.15s ease;
    box-sizing: border-box;
}

.txn-card__input:focus {
    outline: none;
    border-color: var(--primary);
}

.txn-card__input--modified {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

.txn-card__select {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    box-sizing: border-box;
}

.txn-card__select:focus {
    outline: none;
    border-color: var(--primary);
}

.txn-card__select--modified {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

/* Footer */
.txn-card__footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.txn-card__unsaved {
    font-size: 0.75rem;
    color: var(--warning);
    font-weight: 500;
}

.txn-card__actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.txn-card__btn {
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.txn-card__btn--secondary {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.txn-card__btn--secondary:hover {
    background: var(--border);
}

.txn-card__btn--primary {
    background: var(--primary);
    border: none;
    color: white;
}

.txn-card__btn--primary:hover {
    opacity: 0.9;
}

.txn-card__btn--primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .budget-summary-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .budget-summary-bar__stats {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .category-list__item {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .category-list__name {
        min-width: 100%;
    }
    
    .category-list__progress {
        order: 3;
        margin: 0;
        max-width: 100%;
        flex: 1 1 100%;
    }
    
    .category-list__amounts {
        min-width: auto;
    }
    
    .txn-card {
        max-width: 95%;
        margin: 0 10px;
    }
}

/* =================================================================
 * PRIVACY BLUR MODE - Hide sensitive financial data
 * Activated via ?blur=1 URL parameter
 * =================================================================
 */

/* Base blur class applied by JavaScript */
.privacy-blur {
    filter: blur(8px);
    user-select: none;
    transition: filter 0.2s ease;
}

/* Hover to reveal (optional interaction) */
.privacy-blur:hover {
    filter: blur(4px);
}

/* Alternative: show asterisks instead of blur */
.privacy-redact {
    color: transparent !important;
    text-shadow: 0 0 8px currentColor;
    user-select: none;
}

/* Privacy banner when blur mode is active */
#privacyBanner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #374151, #1f2937);
    color: white;
    padding: 10px 20px;
    text-align: center;
    z-index: 99999;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

#privacyBanner .privacy-icon {
    font-size: 1.2rem;
}

#privacyBanner a {
    color: white;
    text-decoration: underline;
    font-weight: 500;
    margin-left: 8px;
}

/* Adjust body padding when banner is present */
body.privacy-mode {
    padding-top: 45px !important;
}

body.privacy-mode .main-content {
    margin-top: 0 !important;
}

/* ===================================
   Privacy Toggle Button Styles
   =================================== */

/* Privacy toggle active state */
#privacyToggleBtn.privacy-active {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    border-color: #dc2626 !important;
    box-shadow: 0 0 12px rgba(220, 38, 38, 0.4);
}

#privacyToggleBtn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.02);
}

#privacyToggleBtn.privacy-active:hover {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
}

/* Animation for toggle */
#privacyToggleBtn {
    transition: all 0.3s ease;
}

#privacyToggleBtn svg {
    transition: transform 0.3s ease;
}

#privacyToggleBtn:active svg {
    transform: scale(0.9);
}

/* Settings accounts page - blur account balances */
[data-account-balance] {
    transition: filter 0.3s ease;
}

body.privacy-mode [data-account-balance] {
    filter: blur(8px);
    user-select: none;
}
