/* ============================================================
   BURGI BUDGET APP — Components
   Buttons, Inputs, Badges, Tables, Glass Cards
   ============================================================ */

/* ── Info Tooltip ── */
.info-tip {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: help;
    opacity: 0.45;
    transition: opacity 0.2s, border-color 0.2s, color 0.2s;
    z-index: 2;
    line-height: 1;
}
/* Inline variant — flows with text, no absolute positioning */
.info-tip-inline {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: help;
    opacity: 0.45;
    transition: opacity 0.2s, border-color 0.2s, color 0.2s;
    vertical-align: middle;
    margin-left: 4px;
    flex-shrink: 0;
}
.info-tip:hover, .info-tip-inline:hover { opacity: 1; border-color: var(--accent-teal); color: var(--accent-teal); }
.info-tip .info-tip-text, .info-tip-inline .info-tip-text {
    display: none;
    position: fixed;
    min-width: 220px;
    max-width: 320px;
    padding: 10px 12px;
    background: #1a2332;
    border: 1px solid rgba(3,206,164,0.2);
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: normal;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    z-index: 9999;
    pointer-events: none;
}
.info-tip:hover .info-tip-text, .info-tip-inline:hover .info-tip-text { display: block; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent-teal);
    color: var(--bg-deepest);
    box-shadow: 0 0 15px rgba(3, 206, 164, 0.25);
}

.btn-primary:hover {
    background: var(--accent-teal-hover);
    box-shadow: 0 0 25px rgba(3, 206, 164, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--accent-teal);
    border: 1px solid var(--accent-teal);
}

.btn-secondary:hover {
    background: rgba(3, 206, 164, 0.1);
    box-shadow: var(--glow-teal);
}

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

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
}

.btn-danger {
    background: transparent;
    color: var(--accent-pink);
    border: 1px solid var(--accent-pink);
}

.btn-danger:hover {
    background: rgba(255, 45, 149, 0.1);
    box-shadow: var(--glow-pink);
}

.btn-sm {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--font-size-xs);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
}

/* ── Inputs ── */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.form-input,
.form-select {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--bg-hover);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--accent-teal);
    box-shadow: 0 0 0 3px rgba(3, 206, 164, 0.1);
}

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

.form-input.mono,
input[type="number"] {
    font-family: var(--font-mono);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ── Color Picker Input ── */
.color-input {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 2px solid var(--bg-hover);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    cursor: pointer;
}

.color-input:focus {
    border-color: var(--accent-teal);
}

/* ── Tables ── */
.table-container {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.data-table th {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-weight: 600;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(3, 206, 164, 0.08);
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.data-table tr:nth-child(even) td {
    background: rgba(15, 26, 40, 0.3);
}

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

.data-table td.amount {
    font-family: var(--font-mono);
    text-align: right;
    font-weight: 500;
}

.data-table td.amount.positive { color: var(--color-positive); }
.data-table td.amount.negative { color: var(--color-negative); }

.data-table tfoot td {
    background: var(--bg-elevated);
    font-weight: 700;
    color: var(--text-primary);
    border-top: 2px solid rgba(3, 206, 164, 0.15);
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-pill);
    font-size: var(--font-size-xs);
    font-weight: 600;
    white-space: nowrap;
}

.badge-paid {
    background: rgba(3, 206, 164, 0.15);
    color: var(--color-paid);
}

.badge-unpaid {
    background: rgba(255, 122, 24, 0.15);
    color: var(--color-unpaid);
}

.badge-closed {
    background: rgba(144, 70, 207, 0.15);
    color: var(--color-closed);
}

.badge-warning {
    background: rgba(255, 214, 10, 0.15);
    color: var(--color-warning);
}

.badge-danger {
    background: rgba(255, 45, 149, 0.15);
    color: var(--color-danger);
}

/* ── Category Badge (with custom color) ── */
.category-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.2rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

/* ── Glass Card ── */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    transition: border-color var(--transition-normal);
}

.glass-card:hover {
    border-color: rgba(3, 206, 164, 0.2);
}

.glass-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* ── Progress Bar ── */
.progress-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--gradient-progress);
    transition: width var(--transition-slow);
    box-shadow: 0 0 8px rgba(3, 206, 164, 0.3);
}

.progress-bar .fill.over-budget {
    background: linear-gradient(90deg, var(--accent-orange), var(--accent-pink));
    box-shadow: 0 0 8px rgba(255, 45, 149, 0.3);
}

/* ── Modal / Overlay ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: var(--overlay-blur);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

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

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}

/* ── Toast Notification ── */
.toast {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    background: var(--toast-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-left: 3px solid var(--accent-teal);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    z-index: var(--z-toast);
    font-size: var(--font-size-sm);
    min-width: 300px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideInRight 0.3s ease;
}

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

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state .empty-text {
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-md);
}

/* ── Dropdown Menu ── */
.dropdown-menu {
    position: absolute;
    background: var(--dropdown-bg);
    border: 1px solid var(--dropdown-border);
    border-radius: var(--radius-md);
    padding: var(--space-xs) 0;
    min-width: 180px;
    z-index: var(--z-dropdown);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.dropdown-item {
    display: block;
    padding: var(--space-sm) var(--space-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    color: var(--text-primary);
    background: rgba(3, 206, 164, 0.05);
}

/* ── Year Grid Popover ── */
.month-picker-label {
    background: transparent;
    border: 1px solid var(--bg-hover);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    font-weight: 600;
    padding: var(--space-xs) var(--space-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.month-picker-label:hover {
    border-color: var(--accent-teal);
    color: var(--accent-teal);
}

.year-grid-popover {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--dropdown-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--dropdown-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    z-index: var(--z-dropdown);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    min-width: 280px;
}

.year-grid-popover.open {
    display: block;
    animation: fadeIn 0.15s ease;
}

.year-grid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.year-grid-year {
    font-weight: 700;
    font-size: var(--font-size-lg);
    color: var(--text-primary);
}

.year-grid-arrow {
    background: transparent;
    border: 1px solid var(--bg-hover);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 2px 10px;
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
}

.year-grid-arrow:hover {
    border-color: var(--accent-teal);
    color: var(--accent-teal);
}

.year-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.month-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    cursor: default;
    color: var(--text-muted);
    background: transparent;
}

.month-tile--exists {
    color: var(--accent-teal);
    border-color: rgba(3, 206, 164, 0.25);
    cursor: pointer;
}

.month-tile--exists:hover {
    background: rgba(3, 206, 164, 0.08);
    border-color: var(--accent-teal);
}

.month-tile--closed {
    color: var(--accent-orange);
    border-color: rgba(255, 122, 24, 0.25);
    cursor: pointer;
}

.month-tile--closed:hover {
    background: rgba(255, 122, 24, 0.08);
    border-color: var(--accent-orange);
}

.month-tile--current {
    color: var(--accent-teal);
    border-color: var(--accent-teal);
    box-shadow: 0 0 12px rgba(3, 206, 164, 0.25);
    background: rgba(3, 206, 164, 0.06);
}

.month-tile--disabled {
    color: var(--text-muted);
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Action Buttons (global) ── */
.btn-add {
    padding: var(--space-sm) var(--space-lg);
    background: var(--accent-teal);
    border: none;
    border-radius: var(--radius-md);
    color: var(--bg-deepest);
    font-weight: 700;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-add:hover {
    background: var(--accent-teal-hover);
    box-shadow: var(--glow-teal);
    transform: translateY(-1px);
}

.btn-edit {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid rgba(3,206,164,0.3);
    border-radius: var(--radius-sm);
    color: var(--accent-teal);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-edit:hover {
    background: rgba(3,206,164,0.1);
    border-color: var(--accent-teal);
    box-shadow: 0 0 8px rgba(3,206,164,0.15);
}

.btn-delete {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid rgba(255,45,149,0.3);
    border-radius: var(--radius-sm);
    color: var(--accent-pink);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-delete:hover {
    background: rgba(255,45,149,0.1);
    border-color: var(--accent-pink);
    box-shadow: 0 0 8px rgba(255,45,149,0.15);
}

.btn-role {
    padding: 4px 12px;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid;
}
.btn-role-promote {
    color: var(--accent-teal);
    border-color: rgba(3,206,164,0.3);
    background: rgba(3,206,164,0.1);
}
.btn-role-promote:hover {
    background: rgba(3,206,164,0.2);
    border-color: var(--accent-teal);
    box-shadow: 0 0 8px rgba(3,206,164,0.15);
}
.btn-role-demote {
    color: #FFB74D;
    border-color: rgba(255,183,77,0.3);
    background: rgba(255,183,77,0.1);
}
.btn-role-demote:hover {
    background: rgba(255,183,77,0.2);
    border-color: #FFB74D;
    box-shadow: 0 0 8px rgba(255,183,77,0.15);
}

.btn-warning {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid rgba(255,122,24,0.3);
    border-radius: var(--radius-sm);
    color: var(--accent-orange);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}
.btn-warning:hover {
    background: rgba(255,122,24,0.1);
    border-color: var(--accent-orange);
    box-shadow: 0 0 8px rgba(255,122,24,0.15);
}

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(3, 206, 164, 0.2); }
    50%      { box-shadow: 0 0 15px rgba(3, 206, 164, 0.4); }
}

.glow-pulse {
    animation: glowPulse 2s ease-in-out infinite;
}

/* ── Mobile responsive: category tables ── */
@media (max-width: 768px) {
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    .data-table th, .data-table td {
        padding: 6px 4px;
        font-size: var(--font-size-xs);
    }
    .data-table td.amount {
        font-size: var(--font-size-xs);
    }

    /* Settings sections */
    .settings-section { padding: var(--space-md); }

    /* Buttons smaller on mobile */
    .btn-add, .btn-edit, .btn-delete {
        padding: 4px 10px;
        font-size: var(--font-size-xs);
    }

    /* Modals full-width on mobile */
    .edit-row-form, .add-form {
        padding: var(--space-md);
    }
}
