/* =========================================
   PREMIUM DESIGN TOKENS
   ========================================= */
:root {
    --bg-gradient: linear-gradient(135deg, #f6f8fd 0%, #f1f5f9 100%);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);

    --text-main: #0f172a;
    --text-muted: #64748b;
    
    --primary: #3a47d5; 
    --primary-gradient: linear-gradient(90deg, #00d2ff 0%, #3a47d5 100%);
    --primary-hover: linear-gradient(90deg, #00bce6 0%, #313cb5 100%); 
    
    --secondary: #0ea5e9;
    --danger: #ef4444;
    --success: #10b981;
    --focus-ring: rgba(79, 70, 229, 0.2);

    --font-sans: 'Inter', sans-serif;

    --ease-fluid: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =========================================
   BASE RESET & NUCLEAR HORIZONTAL LOCK
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    max-width: 100vw;
    overflow-x: hidden !important; 
}

body {
    background-image: var(--bg-gradient);
    min-height: 100vh; 
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden !important; 
    display: flex;
    flex-direction: column;
    color: var(--text-main);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    padding: clamp(1rem, 2vw, 2rem); 
}

.app-header {
    text-align: center;
    margin-block-end: clamp(1rem, 2vw, 1.5rem); 
    flex-shrink: 0; 
}

.app-header h1 {
    font-size: clamp(1.4rem, 3vw, 1.8rem); 
    font-weight: 800;
    letter-spacing: -0.05em;
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.15rem;
}

.subtitle {
    color: var(--text-muted);
    font-weight: 500;
    font-size: clamp(0.8rem, 1.5vw, 0.9rem); 
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

/* =========================================
   MACRO LAYOUT ENGINE 
   ========================================= */
.dashboard-wrapper {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: clamp(1rem, 2vw, 1.5rem); 
    max-width: 1200px;
    margin-inline: auto;
    flex: 1;
    width: 100%;
    min-width: 0; 
    align-items: start; 
}

.input-zone,
.data-zone {
    display: flex;
    flex-direction: column;
    gap: 1rem; 
    min-width: 0; 
    width: 100%;
}

/* =========================================
   GLASSMORPHIC CARDS
   ========================================= */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: clamp(1rem, 2vw, 1.25rem); 
    box-shadow: var(--glass-shadow);
    transition: transform 0.4s var(--ease-fluid), box-shadow 0.4s var(--ease-fluid);
    display: flex;
    flex-direction: column;
    min-width: 0; 
    width: 100%;
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px 0 rgba(31, 38, 135, 0.08);
}

.card-title {
    font-size: 1.05rem; 
    font-weight: 700;
    margin-block-end: 0.8rem; 
    border-bottom: 2px solid rgba(0, 0, 0, 0.03);
    padding-bottom: 0.4rem;
    color: var(--text-main);
}

/* =========================================
   COMPACT FORM CONTROLS
   ========================================= */
.tracker-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem; 
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-group label {
    font-size: 0.75rem; 
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="number"],
input[type="date"],
input[type="text"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem; 
    border: 2px solid transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem; 
    font-weight: 500;
    color: var(--text-main);
    background-color: rgba(0, 0, 0, 0.03);
    transition: all 0.3s var(--ease-fluid);
    outline: none;
    text-overflow: ellipsis; 
}

textarea {
    resize: vertical;
    min-height: 80px;
}

input:focus,
select:focus,
textarea:focus {
    background-color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 0.7rem; 
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
    transition: all 0.3s var(--ease-bounce);
    margin-block-start: 0.25rem;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.3);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
}

.select-wrapper { 
    position: relative; 
    display: block;
    width: 100%;
}

select { 
    appearance: none; 
    -webkit-appearance: none; 
    cursor: pointer; 
    padding-right: 2.5rem !important; 
    width: 100%;
}

.select-wrapper::after {
    content: "";
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%234f46e5%22%20stroke-width%3D%223%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
}

/* =========================================
   PREMIUM FEEDBACK UI
   ========================================= */
.feedback-wrapper {
    max-width: 1200px;
    margin-inline: auto;
    width: 100%;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.premium-feedback-card {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(58, 71, 213, 0.2);
    background: linear-gradient(180deg, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0.4) 100%);
}

.premium-feedback-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: var(--primary-gradient);
}

.feedback-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.premium-input-wrapper {
    position: relative;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.02);
    padding: 2px;
    transition: all 0.3s ease;
}

.premium-input-wrapper:focus-within {
    background: var(--primary-gradient);
    box-shadow: 0 4px 15px rgba(58, 71, 213, 0.15);
}

.premium-input-wrapper input,
.premium-input-wrapper textarea {
    background: #ffffff;
    border: none;
    border-radius: 10px;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.04); 
    margin: 0;
    width: 100%;
    display: block;
}

.feedback-submit-btn {
    align-self: flex-end;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 30px; 
    font-size: 0.85rem;
    width: max-content;
}

.feedback-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(58, 71, 213, 0.3);
}

/* =========================================
   MONTHLY HEATMAP COMPONENTS 
   ========================================= */
.github-wrapper {
    overflow-x: auto;
    padding-bottom: 0.5rem;
    width: 100%;
    min-width: 0; 
}

.github-wrapper::-webkit-scrollbar { height: 6px; }
.github-wrapper::-webkit-scrollbar-thumb { background-color: rgba(0, 0, 0, 0.1); border-radius: 10px; }

.github-heatmap {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, 12px); 
    gap: 4px; 
    padding-block: 4px;
    width: max-content; 
}

.day {
    width: 12px;
    height: 12px;
    min-width: 12px; 
    min-height: 12px;
    border-radius: 2px;
    background: #ebedf0; 
    transition: transform 0.1s ease;
    cursor: pointer;
}

.day:hover {
    transform: scale(1.4);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 10;
}

.lvl-1 { background: #9be9a8; }
.lvl-2 { background: #40c463; }
.lvl-3 { background: #30a14e; }
.lvl-4 { background: #216e39; }

.day.has-expense {
    position: relative;
    box-shadow: inset 0 -3px 0 var(--danger); 
}
.day.has-expense:hover {
    box-shadow: inset 0 -3px 0 var(--danger), 0 2px 5px rgba(0,0,0,0.2);
}

/* =========================================
   ANIMATED BUDGET BAR
   ========================================= */
.budget-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-block-end: 0.5rem;
}

.budget-limit {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.budget-track {
    width: 100%;
    height: 10px; 
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.budget-fill {
    height: 100%;
    width: 0%;
    background-color: var(--success);
    border-radius: 999px;
    transition: width 0.4s var(--ease-fluid), background-color 0.4s ease, opacity 0.2s ease;
    position: relative;
    overflow: hidden;
}

.budget-fill::after {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 50%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer { 100% { left: 200%; } }

/* =========================================
   DASHBOARD METRICS
   ========================================= */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem; 
}

.summary-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.summary-card h3 {
    font-size: 0.75rem; 
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
}

.metric {
    font-size: clamp(1.4rem, 2vw + 1rem, 1.8rem); 
    font-weight: 800;
    margin-block-start: 0.2rem;
    letter-spacing: -0.03em;
}

.highlight-primary { color: var(--primary); }
.highlight-secondary { color: var(--secondary); }

/* =========================================
   HISTORY LIST 
   ========================================= */
.history-container {
    height: auto !important; 
    max-height: none !important; 
    overflow: visible !important; 
    padding-right: 0;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem; 
}

.history-item {
    background: #ffffff;
    padding: 0.75rem 1rem; 
    border-radius: 10px;
    border-left: 4px solid var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem; 
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    transition: all 0.3s var(--ease-fluid);
    animation: slideInFade 0.5s var(--ease-bounce) forwards;
}

.history-item:hover {
    transform: translateX(4px);
    box-shadow: -2px 4px 10px rgba(79, 70, 229, 0.1);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    border: 2px dashed rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
}

.empty-icon {
    width: 36px;
    height: 36px;
    margin-block-end: 0.5rem;
    opacity: 0.4;
    color: var(--primary);
}

/* =========================================
   ENTRANCE CHOREOGRAPHY
   ========================================= */
@keyframes slideInFade {
    0% { opacity: 0; transform: translateY(10px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================
   APP FOOTER 
   ========================================= */
.app-footer {
    position: relative;
    padding-block: 1.5rem 1rem;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.4rem;
}

.footer-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: -0.02em;
}

.author-name {
    font-weight: 800;
    background: linear-gradient(to right, #22d3ee, #3b82f6, #a855f7);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: filter 0.3s ease;
    cursor: pointer;
}

.author-name:hover { filter: brightness(1.25); }
.footer-divider { color: rgba(0, 0, 0, 0.15); margin-inline: 0.5rem; }
.footer-copyright { font-size: 0.8rem; color: rgba(0, 0, 0, 0.4); white-space: nowrap; }

.footer-glow {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.3), transparent);
}

@media (min-width: 768px) {
    .footer-content { flex-direction: row; }
}

/* =========================================
   NEW FEATURE COMPONENT STYLES
   ========================================= */
.btn-share, .btn-reset {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.3s var(--ease-bounce);
}

.btn-share { color: var(--primary); }
.btn-share:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.btn-reset { color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }
.btn-reset:hover {
    background: var(--danger);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);
}

.summary-flex {
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0; 
    transform: translateX(10px);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
}
.history-item:hover .delete-btn { opacity: 1; transform: translateX(0); }
.delete-btn:hover { background-color: #fee2e2; color: var(--danger); }

.edit-icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s var(--ease-bounce);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}
.edit-icon-btn:hover {
    opacity: 1;
    color: var(--primary);
    transform: scale(1.1) rotate(5deg);
}

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none; 
}
.toast {
    background: #ffffff;
    border-left: 4px solid var(--primary);
    padding: 0.85rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    animation: slideInRight 0.4s var(--ease-bounce) forwards;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast.fade-out { animation: fadeOutRight 0.3s ease forwards; }

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

/* =========================================
   INTERACTIVE DONUT CHART & TOOLTIP
   ========================================= */
.donut-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: crosshair;
}

.donut-chart {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #e2e8f0; 
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.4s var(--ease-bounce), box-shadow 0.4s ease;
}

.donut-chart::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 25px;
    height: 25px;
    background: var(--glass-bg);
    border-radius: 50%;
}

.custom-tooltip {
    position: absolute;
    top: 120%; 
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 0.85rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(31, 38, 135, 0.2);
    width: max-content;
    min-width: 210px;
    z-index: 9999; 
    
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s var(--ease-bounce);
}

.donut-wrapper:hover .donut-chart {
    transform: scale(1.25);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.donut-wrapper:hover .custom-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.tooltip-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding-bottom: 0.3rem;
}

.tooltip-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.cat-name { color: var(--text-main); font-weight: 600; }
.cat-value { color: var(--text-main); font-weight: 800; margin-left: auto; padding-left: 1rem;}

/* =========================================
   RESPONSIVE LAYOUT STACKING (Strict Control)
   ========================================= */
@media (max-width: 1024px) {
    .dashboard-wrapper { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 850px) {
    .dashboard-wrapper {
        grid-template-columns: 1fr; 
    }
}

@media (max-width: 600px) {
    body { padding-inline: 1rem; }
    .card-title { font-size: 0.95rem; }
    
    .history-container, .input-zone, .data-zone, .feedback-wrapper {
        height: auto !important;
        overflow: visible !important;
    }
    
    .feedback-wrapper .form-group {
        flex-direction: column;
    }
}