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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    transition: background-color 0.3s, color 0.3s;
    /* Ensure body doesn't hide the fixed gradient initially, but provides defaults */
}

.dark {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

/* ==== ANIMATED GRADIENT BACKGROUND ==== */
.auth-background {
    background: linear-gradient(125deg, #020617, #1e1b4b, #7c3aed, #2e1065, #0c4a6e, #1e1b4b);
    background-size: 400% 400%;
    animation: gradient 15s ease infinite;
    height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    z-index: -1;
}

@keyframes gradient {
    0% { background-position: 0% 50%; }
    25% { background-position: 50% 100%; }
    50% { background-position: 100% 50%; }
    75% { background-position: 50% 0%; }
    100% { background-position: 0% 50%; }
}

/* ==== AUTH PAGE LAYOUT ==== */
#authScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-title {
    font-size: 4rem;
    font-weight: 900;
    color: #f8fafc;
    margin-bottom: 2rem;
    text-shadow: 0 0 40px rgba(139, 92, 246, 0.5);
    text-align: center;
    letter-spacing: -2px;
}

.auth-card {
    position: relative;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-width: 28rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 0 rgba(255, 255, 255, 0.1);
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 24px;
    padding: 2px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899, #3b82f6, #6366f1);
    background-size: 300% 300%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: borderGradient 4s ease infinite;
    z-index: -1;
}

@keyframes borderGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.auth-input {
    background: rgba(2, 6, 23, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
    transition: all 0.3s ease;
}

.auth-input:focus {
    background: rgba(2, 6, 23, 0.8) !important;
    border-color: #8b5cf6 !important;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15) !important;
}

.auth-input::placeholder {
    color: rgba(148, 163, 184, 0.5) !important;
}

.gradient-btn {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 16px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    text-align: center;
    margin-bottom: 1rem;
    display: block;
    box-shadow: 0 10px 15px -3px rgba(124, 58, 237, 0.3);
}

.gradient-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(124, 58, 237, 0.4);
    filter: brightness(1.1);
}


/* Ensure the Main App covers the auth gradient when logged in */
#mainApp {
    background-color: #ffffff; 
    min-height: 100vh;
    position: relative;
    z-index: 1; /* Sit above the fixed auth background */
}

.dark #mainApp {
    background-color: #1a1a1a;
}

/* ==== CALENDAR ==== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.calendar-day:hover {
    transform: scale(1.05);
}

.calendar-day.today {
    border: 2px solid #3b82f6;
}

.calendar-day.has-tags {
    font-weight: bold;
}

.tag-dots {
    display: flex;
    gap: 2px;
    margin-top: 4px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
}

.tag-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    z-index: 100;
}

.dark .bottom-nav {
    background: #2a2a2a;
    border-top-color: #404040;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.nav-item:hover {
    background-color: #f3f4f6;
}

.dark .nav-item:hover {
    background-color: #3a3a3a;
}

.nav-item.active {
    color: #3b82f6;
}

/* ==== MODAL ==== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.dark .modal-content {
    background: #2a2a2a;
}

/* ==== TAG CHECKBOX ==== */
.tag-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.tag-checkbox:hover {
    background-color: #f3f4f6;
}

.dark .tag-checkbox:hover {
    background-color: #3a3a3a;
}

/* ==== COLOR PICKER ==== */
.color-picker-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    position: relative;
}

.color-option:hover:not(.disabled) {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: #3b82f6;
    transform: scale(1.15);
}

.color-option.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.color-option.disabled::after {
    content: '✕';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 20px;
    text-shadow: 0 0 3px rgba(0,0,0,0.5);
}

.premium-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
    margin-left: 8px;
    text-transform: uppercase;
}

/* ==== CUSTOM COLOR INPUT ==== */
.custom-color-input {
    width: 100%;
    padding: 8px;
    border: 2px dashed #9ca3af;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    background: #f9fafb;
}

.dark .custom-color-input {
    background: #3a3a3a;
    border-color: #6b7280;
}

.custom-color-input:hover {
    border-color: #667eea;
    background: #f3f4f6;
}

.custom-color-input.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==== CONTENT AREA ==== */
.content-area {
    padding: 20px;
    padding-bottom: 80px;
    max-width: 800px;
    margin: 0 auto;
}

/* ==== TABS ==== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #e5e7eb;
    color: #1f2937;
}

.dark .btn-secondary {
    background: #404040;
    color: #e0e0e0;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* ==== INPUT ==== */
input, select, textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    color: #1f2937;
}

.dark input, .dark select, .dark textarea {
    background: #3a3a3a;
    border-color: #404040;
    color: #e0e0e0;
}

/* ==== STATS CARD ==== */
.stats-card {
    background: #f9fafb;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.dark .stats-card {
    background: #2a2a2a;
}

/* ==== STREAK BADGE ==== */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: #fef3c7;
    color: #92400e;
    font-size: 14px;
    font-weight: 600;
}

.dark .streak-badge {
    background: #78350f;
    color: #fef3c7;
}

/* ==== PROGRESS BAR ==== */
.progress-bar {
    width: 100%;
    height: 12px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.dark .progress-bar {
    background: #404040;
}

.progress-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 6px;
    transition: width 0.3s;
}

/* ==== PERIOD FILTER ==== */
.period-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.period-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    background: white;
    color: #1f2937;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
}

.dark .period-btn {
    background: #3a3a3a;
    border-color: #404040;
    color: #e0e0e0;
}

.period-btn:hover:not(.disabled) {
    border-color: #3b82f6;
    background: #eff6ff;
}

.dark .period-btn:hover:not(.disabled) {
    background: #1e3a5f;
}

.period-btn.active {
    border-color: #3b82f6;
    background: #3b82f6;
    color: white;
}

.period-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==== CHART CONTAINER ==== */
.chart-container {
    position: relative;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==== PREMIUM LOCKED ==== */
.btn-premium-locked {
    position: relative;
    opacity: 0.7;
    cursor: not-allowed;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-premium-locked:hover {
    opacity: 0.7;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ==== KEYBOARD SHORTCUTS ==== */
.kbd {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    font-family: monospace;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.dark .kbd {
    background: #374151;
    border-color: #4b5563;
}

/* ==== SEARCH HIGHLIGHT ==== */
input[type="text"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ==== SMOOTH ANIMATIONS ==== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stats-card {
    animation: fadeIn 0.3s ease-out;
}

/* ==== MOBILE RESPONSIVE ==== */
@media (max-width: 640px) {
    .content-area {
        padding: 15px;
        padding-bottom: 80px;
    }

    .modal-content {
        padding: 20px;
        max-height: 85vh;
    }

    .calendar-day {
        font-size: 14px;
    }

    /* Auth Responsive */
    .auth-title {
        font-size: 3rem;
        margin-bottom: 1.5rem;
    }
    
    .auth-card {
        padding: 2rem;
        max-width: 95%;
    }
}

/* Custom Modal */
.modal-custom {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-out;
}

.modal-custom-content {
    position: relative;
    margin: auto;
    padding: 2px;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    background: linear-gradient(145deg, #89f7fe, #66a6ff);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    display: flex;
    flex-direction: column;
}

.dark .modal-custom-content {
    background: linear-gradient(145deg, #374151, #111827);
}

.modal-custom-inner {
    background-color: #ffffff;
    padding: 24px;
    border-radius: 14px;
}

.dark .modal-custom-inner {
    background-color: #1f2937;
}

.modal-custom-header {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: #111827;
}

.dark .modal-custom-header {
    color: #ffffff;
}

.modal-custom-body {
    margin-bottom: 24px;
    font-size: 1rem;
    line-height: 1.5;
    color: #374151;
}

.dark .modal-custom-body {
    color: #d1d5db;
}

.modal-custom-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-custom-button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-custom-button-primary {
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.modal-custom-button-secondary {
    background-color: #e5e7eb;
    color: #1f2937;
}

.dark .modal-custom-button-secondary {
    background-color: #4b5563;
    color: #ffffff;
}
