/* ===================================================== 
   ROOT VARIABLES 
===================================================== */
:root {
    --bg-light: #f4f6fb;
    --bg-dark: #0f1220;
    --glass-light: rgba(255, 255, 255, 0.65);
    --glass-dark: rgba(25, 25, 45, 0.7);
    --text-light: #111;
    --text-dark: #ffffff;
    --accent: #6c63ff;
    --danger: #ef4444;
    --radius: 22px;
    --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ===================================================== 
   RESET & BASE 
===================================================== */
* {
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding-bottom: 140px;
    /* Space for bottom nav */
    background: radial-gradient(circle at top, #eef1ff, var(--bg-light));
    color: var(--text-light);
    transition: background 0.35s var(--ease), color 0.35s var(--ease);
    min-height: 100vh;
}

body.dark {
    background: radial-gradient(circle at top, #161a3a, var(--bg-dark));
    color: var(--text-dark);
}

/* ===================================================== 
   TOP BAR & PROGRESS (RESTORED STRUCTURE)
===================================================== */
.topbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px 20px;
    max-width: 520px;
    margin: 0 auto;
}

.topbar h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    color: var(--accent);
}

.top-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.top-actions button {
    background: var(--glass-light);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 8px;
    font-size: 20px;
    cursor: pointer;
    color: inherit;
    backdrop-filter: blur(10px);
}

body.dark .top-actions button {
    background: var(--glass-dark);
    border-color: rgba(255, 255, 255, 0.1);
}

.progress-wrap {
    width: 100%;
}

.progress-text {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    opacity: 0.9;
}

.progress-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

body.dark .progress-bar {
    background: rgba(255, 255, 255, 0.1);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6c63ff, #8f88ff);
    transition: width 0.5s var(--ease);
    box-shadow: 0 0 10px rgba(108, 99, 255, 0.3);
}

.streak-box {
    font-size: 14px;
    font-weight: 700;
    background: rgba(255, 107, 0, 0.1);
    color: #ff6b00;
    padding: 6px 12px;
    border-radius: 20px;
    display: inline-block;
    width: fit-content;
}

/* ===================================================== 
   TASK CARDS (RESTORED TO ORIGINAL SIZING)
===================================================== */
.container {
    max-width: 520px;
    margin: auto;
    padding: 0 20px;
}

.card {
    background: var(--glass-light);
    backdrop-filter: blur(25px) saturate(160%);
    -webkit-backdrop-filter: blur(25px) saturate(160%);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 14px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeUp 0.4s var(--ease);
}

body.dark .card {
    background: var(--glass-dark);
    border-color: rgba(255, 255, 255, 0.08);
}

.task-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.task-left strong {
    font-size: 16px;
    display: block;
}

.task-left small {
    opacity: 0.6;
    font-size: 13px;
}

.card button {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.card button:hover {
    opacity: 1;
}

/* ===================================================== 
   INPUTS (FIXED NO-BREAK)
===================================================== */
input[type="text"],
input[type="time"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: white;
    outline: none;
    font-size: 15px;
    /* Bug Fix: prevent expanding the container */
    box-sizing: border-box;
}

body.dark input {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border-color: rgba(255, 255, 255, 0.1);
}

/* ===================================================== 
   CHECKBOX (REMIX ICON SYNC)
===================================================== */
.task input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.2);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

body.dark .task input[type="checkbox"] {
    border-color: rgba(255, 255, 255, 0.3);
}

.task input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.task input[type="checkbox"]:checked::after {
    content: "✓";
    position: absolute;
    color: white;
    font-weight: 900;
    font-size: 14px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* ===================================================== 
   BOTTOM NAV & MODAL 
===================================================== */
.bottom-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 480px;
    background: var(--glass-light);
    backdrop-filter: blur(20px);
    border-radius: 28px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    z-index: 1000;
}

body.dark .bottom-nav {
    background: var(--glass-dark);
}

.nav-item {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 11px;
    opacity: 0.6;
}

.nav-item.active {
    opacity: 1;
    color: var(--accent);
}

.nav-item span {
    font-size: 22px;
}

.nav-add {
    width: 60px;
    height: 60px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    border: none;
    font-size: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-30px);
    box-shadow: 0 10px 20px rgba(108, 99, 255, 0.4);
    cursor: pointer;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-sheet {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 30px 30px 0 0;
    animation: slideUp 0.3s ease;
}

body.dark .modal-sheet {
    background: var(--bg-dark);
}

/* ===================================================== 
   ANIMATIONS 
===================================================== */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* ===================================================== 
   SPLASH (REMIXED) 
===================================================== */
#splash {
    position: fixed;
    inset: 0;
    background: var(--accent);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 9999;
}

/* ===================================================== 
   ADD HABIT MODAL (ENHANCED GLASS BOTTOM SHEET) 
===================================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4); /* Darken background for focus */
    display: flex;
    align-items: flex-end; /* Mobile-friendly bottom sheet look */
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none;
    opacity: 0;
}

.modal-sheet {
    width: 100%;
    max-width: 450px; /* Limits width on desktop */
    background: var(--glass-light);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    padding: 32px 24px;
    border-radius: 32px 32px 0 0; /* Rounded top corners */
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

body.dark .modal-sheet {
    background: var(--glass-dark);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Modal Title */
.modal-sheet h3 {
    margin: 0 0 20px;
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    text-align: left;
}

/* Modal Inputs */
.modal-sheet input {
    width: 100%;
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    outline: none;
    box-sizing: border-box; /* Crucial fix for layout breakage */
    transition: all 0.2s ease;
}

body.dark .modal-sheet input {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.modal-sheet input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.15);
}

/* Button Container for Layout */
.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

/* Modal Buttons Styling */
.modal-sheet button {
    flex: 1;
    padding: 16px;
    border-radius: 16px;
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

#modalAddBtn {
    background: linear-gradient(135deg, #6c63ff, #4f46e5);
    color: white;
    box-shadow: 0 8px 20px rgba(108, 99, 255, 0.3);
}

#modalAddBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(108, 99, 255, 0.4);
}

.close-modal {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-light);
}

body.dark .close-modal {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.modal-sheet button:active {
    transform: scale(0.96);
}

/* Animation for sliding up from bottom */
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ===================================================== 
   ADD HABIT MODAL (CENTERED VERSION) 
===================================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6); /* Slightly darker for focus */
    display: flex;
    align-items: center; /* Vertical centering */
    justify-content: center; /* Horizontal centering */
    z-index: 2000;
    backdrop-filter: blur(8px);
    padding: 20px; /* Padding for mobile screens */
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none;
    opacity: 0;
}

.modal-sheet {
    width: 100%;
    max-width: 380px; /* Consistent with Login/Signup cards */
    background: var(--glass-light);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    padding: 40px 32px;
    border-radius: var(--radius); /* Uses your global 22px or 32px radius */
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.2);
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark .modal-sheet {
    background: var(--glass-dark);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Updated zoom animation for a premium feel */
@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Ensure actions stack or spread properly */
.modal-actions {
    display: flex;
    flex-direction: column; /* Stacked buttons for mobile ease-of-use */
    gap: 12px;
    margin-top: 20px;
}

#modalAddBtn {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 16px;
    font-weight: 700;
    cursor: pointer;
}

.close-modal {
    background: transparent;
    border: 1px solid rgba(0,0,0,0.1);
    color: inherit;
    width: 100%;
    padding: 14px;
    border-radius: 16px;
    cursor: pointer;
}
