/* ======================================
   NEUROHABIT STYLES - FINAL VERSION
   ====================================== */

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #581c87 50%, #0f172a 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: white;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.5);
}

::-webkit-scrollbar-thumb {
    background: rgba(168, 85, 247, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(168, 85, 247, 0.8);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    box-sizing: border-box;
}

@supports (padding: max(0px)) {
    .container {
        padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* ======================================
   AUTH SCREENS
   ====================================== */

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.auth-card {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 1.5rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 1rem;
}

.auth-title {
    font-size: 1.875rem;
    font-weight: bold;
    background: linear-gradient(135deg, #c084fc 0%, #f9a8d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: #94a3b8;
    font-size: 0.875rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: #cbd5e1;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(51, 65, 85, 0.5);
    border: 1px solid #475569;
    border-radius: 0.75rem;
    color: white;
    font-size: 1rem;
    transition: all 0.3s;
}

.form-input:focus {
    outline: none;
    border-color: #a855f7;
    background: rgba(51, 65, 85, 0.7);
}

.form-error {
    margin-top: 0.375rem;
    font-size: 0.8rem;
    color: #fda4af;
    min-height: 1rem;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 0.875rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, #9333ea 0%, #db2777 100%);
    color: white;
}

.btn-primary:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(147, 51, 234, 0.3);
}

.btn-google {
    background: white;
    color: #1f2937;
    margin-top: 1rem;
}

.btn-google:hover {
    background: #f3f4f6;
    transform: scale(1.02);
}

.btn-cancel {
    background: #475569;
    color: white;
}

.btn-cancel:hover {
    background: #64748b;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: #64748b;
    font-size: 0.875rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #475569;
}

.divider span {
    padding: 0 1rem;
}

/* Auth Link */
.auth-link {
    text-align: center;
    margin-top: 1.5rem;
    color: #94a3b8;
    font-size: 0.875rem;
}

.auth-link a {
    color: #a855f7;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.auth-link a:hover {
    color: #c084fc;
}

/* ======================================
   MAIN APP - HEADER
   ====================================== */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    padding: 0.75rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text h1 {
    font-size: 1.875rem;
    font-weight: bold;
    background: linear-gradient(135deg, #c084fc 0%, #f9a8d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text p {
    font-size: 0.875rem;
    color: #94a3b8;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-insights {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #9333ea 0%, #db2777 100%);
    padding: 0.75rem 1.25rem;
    border-radius: 0.75rem;
    border: none;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-insights:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(147, 51, 234, 0.3);
}

.btn-logout {
    padding: 0.75rem 1.25rem;
    background: rgba(51, 65, 85, 0.5);
    border: 1px solid #475569;
    border-radius: 0.75rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

/* Profile Container Styles */
.profile-container {
    position: relative;
}

.profile-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
    border: 1px solid rgba(168, 85, 247, 0.5);
    border-radius: 0.75rem;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.profile-button:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.3);
}

.profile-username {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 1rem;
    padding: 1.5rem;
    min-width: 280px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: slideDown 0.3s ease-out;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-dropdown.hidden {
    display: none;
}

.profile-dropdown-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(168, 85, 247, 0.2);
    font-weight: 600;
    font-size: 1.1rem;
    color: #f1f5f9;
}

.profile-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(148, 113, 233, 0.1);
    border-radius: 0.5rem;
    border-left: 3px solid #a855f7;
}

.profile-info-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #c084fc;
}

.profile-info-value {
    color: #f1f5f9;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    font-size: 0.95rem;
}

.password-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.password-hidden {
    font-weight: bold;
    letter-spacing: 0.3em;
}

.btn-toggle-password {
    padding: 0.4rem;
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 0.4rem;
    color: #a855f7;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle-password:hover {
    background: rgba(168, 85, 247, 0.4);
    border-color: rgba(168, 85, 247, 0.6);
}

.btn-logout-dropdown {
    width: 100%;
    padding: 0.75rem;
    margin-top: 1rem;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.3), rgba(225, 29, 72, 0.3));
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 0.5rem;
    color: #fca5a5;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.btn-logout-dropdown:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.5), rgba(225, 29, 72, 0.5));
    border-color: rgba(239, 68, 68, 0.8);
}

/* ======================================
   NAVIGATION TABS
   ====================================== */

.nav-tabs {
    display: flex;
    gap: 1rem;
    background: rgba(30, 41, 59, 0.5);
    padding: 0.5rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
}

.nav-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-tab.active {
    background: #9333ea;
    box-shadow: 0 10px 30px rgba(147, 51, 234, 0.3);
}

.nav-tab:hover:not(.active) {
    background: rgba(71, 85, 105, 0.5);
}

/* ======================================
   STATS GRID
   ====================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    padding: 1.25rem;
    border-radius: 1rem;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(139, 92, 246, 0.2);
}

.stat-value {
    font-size: 1.875rem;
    font-weight: bold;
}

.stat-label {
    font-size: 0.875rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

.habit-weekly-progress {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    width: 100%;
}

.habit-weekly-label {
    grid-column: 1 / 2;
    font-size: 0.8rem;
    color: #94a3b8;
    min-width: 0;
}

.habit-weekly-count {
    grid-column: 2 / 3;
    font-size: 0.8rem;
    color: #38bdf8;
    text-align: right;
    flex-shrink: 0;
}

.habit-weekly-bar {
    grid-column: 1 / 3;
    position: relative;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(30, 64, 175, 0.4);
    overflow: hidden;
}

.habit-weekly-fill {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    transition: width 0.25s ease-out;
}

/* Quick action cards (Tambah Habit Baru & AI Insights) */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.25rem 0 1rem;
}

.quick-action-card {
    flex: 1 1 240px;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.9rem 1.25rem;
    border-radius: 999px;
    border: 1px solid rgba(30, 64, 175, 0.4);
    background: rgba(139, 92, 246, 0.2);
    color: #f3f4f6;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.quick-action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.7);
    border-color: rgba(165, 180, 252, 0.5);
}

.quick-action-icon {
    width: 32px;
    height: 32px;
    border-radius: 0.9rem;
    flex-shrink: 0;
}

.quick-action-icon-add {
    background: #e879f9;
}

.quick-action-icon-ai {
    background: #fb923c;
}

.quick-action-text {
    display: flex;
    flex-direction: column;
}

.quick-action-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.quick-action-subtitle {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* ======================================
   HABIT CARD
   ====================================== */

.habit-card {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(20px);
    padding: 1.25rem;
    border-radius: 1rem;
    border: 1px solid rgba(139, 92, 246, 0.2);
    margin-bottom: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.habit-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 60px rgba(168, 85, 247, 0.3);
    border-color: rgba(168, 85, 247, 0.5);
}

.habit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.habit-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.habit-icon {
    padding: 0.5rem;
    border-radius: 0.75rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 3rem;
    min-height: 3rem;
}

.habit-name {
    font-weight: 600;
    font-size: 1.125rem;
}

.habit-streak {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

.habit-meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.25rem;
    font-size: 0.8rem;
}

.habit-streak-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.15);
    color: #bbf7d0;
}

.habit-target {
    color: #e5e7eb;
}

.btn-edit-emoji {
    background: transparent;
    border: none;
    color: #cbd5e1;
    font-size: 1rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit-emoji:hover {
    background: rgba(71, 85, 105, 0.5);
}

/* ======================================
   DAYS TRACKER
   ====================================== */

.days-tracker {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
}

.day-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.day-item:not([onclick]) {
    cursor: not-allowed;
    opacity: 0.6;
}

.day-item[onclick] {
    cursor: pointer;
}

.day-item[onclick]:hover {
    background: rgba(71, 85, 105, 0.3);
}

.day-label {
    font-size: 0.75rem;
    color: #94a3b8;
}

.day-box {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border: 2px solid rgba(100, 116, 139, 0.3);
    background: rgba(15, 23, 42, 0.6);
}

.day-box.completed {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(52, 211, 153, 0.7);
    box-shadow: 0 4px 12px rgba(52, 211, 153, 0.4);
}

.day-box.missed {
    background: transparent;
    border-style: dashed;
    border-color: rgba(148, 163, 184, 0.5);
}

.day-box.empty {
    background: rgba(15, 23, 42, 0.4);
    border-color: rgba(75, 85, 99, 0.6);
}

.day-box.today {
    border-color: #a855f7;
    box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.7);
}

.day-today {
    font-size: 0.7rem;
    color: #e879f9;
}

.day-missed {
    font-size: 1rem;
    color: #f97316;
}

.day-num {
    font-size: 0.75rem;
    color: #64748b;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ======================================
   MODALS
   ====================================== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
}

.modal-content {
    background: #1e293b;
    border-radius: 1.5rem;
    padding: 2rem;
    max-width: 42rem;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid rgba(168, 85, 247, 0.5);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: bold;
}

.btn-close {
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.3s;
}

.btn-close:hover {
    background: #475569;
}

/* ======================================
   INSIGHTS & ANALYTICS
   ====================================== */

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.insight-card {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    padding: 1.25rem;
    border-radius: 0.75rem;
}

.insight-value {
    font-size: 1.875rem;
    font-weight: bold;
}

.insight-label {
    font-size: 0.875rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

.insight-detail {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.5rem;
}

.analytics-section {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(20px);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(139, 92, 246, 0.2);
    margin-bottom: 1.5rem;
}

.performance-trend-container {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(168, 85, 247, 0.15);
    position: relative;
    height: 300px;
}

.performance-trend-container canvas {
    max-height: 100%;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 1.25rem;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 1rem;
}

/* Performance */
.habit-performance {
    margin-bottom: 1.5rem;
}

.performance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.performance-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.performance-rate {
    font-size: 0.875rem;
    color: #94a3b8;
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 0.5rem;
    background: rgba(71, 85, 105, 0.5);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #a855f7 0%, #ec4899 100%);
    border-radius: 9999px;
    transition: width 0.5s ease;
}

/* Correlations */
.correlation-section,
.recommendation-section {
    background: rgba(71, 85, 105, 0.3);
    padding: 1.25rem;
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
}

.correlation-item {
    margin-bottom: 1rem;
}

.correlation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.correlation-text {
    font-size: 0.875rem;
}

.correlation-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: #4ade80;
}

/* Recommendations */
.recommendation-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(71, 85, 105, 0.3);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.recommendation-number {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background: #9333ea;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
}

.recommendation-text {
    font-size: 0.875rem;
    color: #cbd5e1;
}

/* ======================================
   CALENDAR
   ====================================== */

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all 0.2s;
    background: rgba(71, 85, 105, 0.2);
}

.calendar-day:hover {
    background: rgba(71, 85, 105, 0.4);
}

.calendar-header {
    text-align: center;
    font-size: 0.875rem;
    color: #94a3b8;
    font-weight: 600;
    padding: 0.5rem 0;
}

/* ======================================
   ADD HABIT FORM
   ====================================== */

.add-habit-form {
    background: rgba(30, 41, 59, 0.5);
    padding: 1.25rem;
    border-radius: 1rem;
    border: 1px solid rgba(168, 85, 247, 0.3);
    margin-top: 1rem;
}

.add-habit-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(71, 85, 105, 0.5);
    border: 1px solid #475569;
    border-radius: 0.75rem;
    color: white;
    margin-bottom: 0.75rem;
}

.add-habit-input:focus {
    outline: none;
    border-color: #a855f7;
}

.form-buttons {
    display: flex;
    gap: 0.5rem;
}

.form-buttons button {
    flex: 1;
    padding: 0.625rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-add {
    background: #9333ea;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add:hover {
    background: #7e22ce;
}

/* ======================================
   TOAST NOTIFICATIONS
   ====================================== */

#toastContainer {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: rgba(34, 197, 94, 0.9);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
    animation: slideIn 0.3s ease-out;
}

.toast.error {
    background: rgba(239, 68, 68, 0.9);
}

/* AI Coach */
.ai-coach-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ai-messages {
    max-height: 320px;
    overflow-y: auto;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.ai-message {
    display: flex;
    margin-bottom: 0.5rem;
}

.ai-message-user {
    justify-content: flex-end;
}

.ai-message-ai {
    justify-content: flex-start;
}

.ai-bubble {
    max-width: 80%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

.ai-bubble-user {
    background: linear-gradient(135deg, #9333ea, #db2777);
}

.ai-bubble-ai {
    background: rgba(30, 64, 175, 0.75);
}

.ai-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.ai-input {
    resize: vertical;
}

/* ======================================
   RESPONSIVE DESIGN
   ====================================== */

/* TABLET & MEDIUM DEVICES (768px and below) */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    body {
        min-height: 100vh;
    }

    .container {
        padding: 0.75rem;
        max-width: 100%;
    }

    /* Header Responsive */
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .logo-section {
        width: 100%;
        justify-content: flex-start;
    }

    .logo-text h1 {
        font-size: 1.5rem;
    }

    .logo-text p {
        font-size: 0.75rem;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .profile-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .profile-username {
        max-width: 80px;
    }

    .profile-dropdown {
        min-width: 240px;
        padding: 1rem;
        right: -10px;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    /* Navigation Tabs */
    .nav-tabs {
        gap: 0.5rem;
        padding: 0.4rem;
        margin-bottom: 1rem;
    }

    .nav-tab {
        padding: 0.6rem 0.5rem;
        font-size: 0.75rem;
        gap: 0.3rem;
    }

    /* Habit Cards */
    .habit-card {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }

    .habit-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .habit-icon {
        min-width: 2.5rem;
        min-height: 2.5rem;
        font-size: 1.25rem;
    }

    .habit-name {
        font-size: 1rem;
    }

    .habit-actions {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }

    .btn-habit-action {
        flex: 1;
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    /* Quick Actions */
    .quick-actions {
        flex-direction: column;
        gap: 0.75rem;
        margin: 1rem 0;
    }

    .quick-action-card {
        flex: 1 1 100%;
        padding: 0.75rem 1rem;
        border-radius: 0.75rem;
        font-size: 0.9rem;
    }

    .quick-action-icon {
        width: 28px;
        height: 28px;
    }

    .quick-action-title {
        font-size: 0.85rem;
    }

    .quick-action-subtitle {
        font-size: 0.7rem;
    }

    /* Days Tracker */
    .days-tracker {
        gap: 0.25rem;
        margin-bottom: 1rem;
    }

    .day-item {
        padding: 0.3rem;
        gap: 0.15rem;
    }

    .day-box {
        width: 2rem;
        height: 2rem;
        font-size: 0.8rem;
    }

    .day-label {
        font-size: 0.7rem;
    }

    /* Modals */
    .modal {
        padding: 0.5rem;
    }

    .modal-content {
        padding: 1.5rem 1rem;
        max-width: 100%;
        border-radius: 1rem;
    }

    .modal-title {
        font-size: 1.25rem;
    }

    /* Auth Card */
    .auth-container {
        padding: 0.5rem;
    }

    .auth-card {
        padding: 1.5rem 1rem;
        max-width: 100%;
    }

    .auth-title {
        font-size: 1.5rem;
    }

    .form-input {
        padding: 0.6rem 0.75rem;
        font-size: 0.95rem;
    }

    .btn {
        padding: 0.7rem;
        font-size: 0.9rem;
    }

    /* Insights Grid */
    .insights-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .insight-card {
        padding: 1rem;
    }

    .insight-value {
        font-size: 1.5rem;
    }

    /* AI Coach - compact di tablet & mobile */
    .ai-messages {
        max-height: 260px;
        padding: 0.5rem;
    }

    .ai-bubble {
        max-width: 88%;
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    .ai-input-row {
        gap: 0.4rem;
    }

    .ai-input {
        min-height: 36px;
        font-size: 0.85rem;
    }

    /* Performance Trend Container */
    .performance-trend-container {
        height: 250px;
        padding: 1rem;
    }

    /* Calendar & Analytics */
    .calendar-container {
        padding: 0;
    }

    .analytics-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .section-header {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
}

/* MOBILE PORTRAIT (480px and below) */
@media (max-width: 480px) {
    html {
        font-size: 13px;
    }

    .container {
        padding: 0.5rem;
    }

    /* Header untuk Mobile Portrait */
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .logo-section {
        gap: 0.5rem;
    }

    .logo-icon {
        padding: 0.5rem;
    }

    .logo-icon i {
        width: 24px !important;
        height: 24px !important;
    }

    .logo-text h1 {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    .logo-text p {
        font-size: 0.65rem;
    }

    .header-actions {
        width: 100%;
        gap: 0.4rem;
    }

    .btn-insights {
        padding: 0.5rem;
        min-width: 36px;
        font-size: 0.8rem;
    }

    .profile-button {
        padding: 0.5rem 0.6rem;
        font-size: 0.8rem;
        gap: 0.4rem;
    }

    .profile-button i {
        width: 18px !important;
        height: 18px !important;
    }

    .profile-username {
        max-width: 60px;
        font-size: 0.75rem;
    }

    .profile-dropdown {
        min-width: 200px;
        padding: 0.75rem;
        right: -20px;
    }

    .profile-dropdown-header {
        gap: 0.75rem;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
        font-size: 0.95rem;
    }

    .profile-info-item {
        gap: 0.4rem;
        margin-bottom: 0.75rem;
        padding: 0.5rem;
    }

    /* Stats Grid untuk Mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.65rem;
        margin-top: 0.15rem;
    }

    /* Navigation Tabs Mobile */
    .nav-tabs {
        gap: 0.3rem;
        padding: 0.3rem;
        margin-bottom: 0.75rem;
    }

    .nav-tab {
        padding: 0.5rem 0.3rem;
        font-size: 0.65rem;
        gap: 0.2rem;
    }

    .nav-tab i {
        width: 16px !important;
        height: 16px !important;
    }

    /* Habit Cards Mobile */
    .habit-card {
        padding: 0.75rem;
        margin-bottom: 0.6rem;
        border-radius: 0.75rem;
    }

    .habit-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .habit-icon {
        min-width: 2.25rem;
        min-height: 2.25rem;
        padding: 0.4rem;
        font-size: 1rem;
    }

    .habit-info {
        width: 100%;
        flex-direction: column;
        gap: 0.3rem;
    }

    .habit-name {
        font-size: 0.9rem;
    }

    .habit-streak {
        font-size: 0.75rem;
        gap: 0.3rem;
        margin-top: 0.1rem;
    }

    .habit-meta-line {
        gap: 0.4rem;
        font-size: 0.7rem;
    }

    .habit-actions {
        width: 100%;
        display: flex;
        gap: 0.4rem;
        flex-wrap: wrap;
    }

    .btn-habit-action {
        flex: 1;
        min-width: 70px;
        padding: 0.4rem 0.5rem;
        font-size: 0.65rem;
        height: auto;
    }

    .btn-habit-action i {
        width: 14px !important;
        height: 14px !important;
    }

    /* Quick Actions Mobile */
    .quick-actions {
        flex-direction: column;
        gap: 0.5rem;
        margin: 0.75rem 0 0.75rem 0;
    }

    .quick-action-card {
        flex: 1 1 100%;
        padding: 0.6rem 0.75rem;
        border-radius: 0.5rem;
        gap: 0.6rem;
    }

    .quick-action-card:active {
        transform: scale(0.98);
    }

    .quick-action-icon {
        width: 24px;
        height: 24px;
    }

    .quick-action-text {
        gap: 0.2rem;
    }

    .quick-action-title {
        font-size: 0.8rem;
        font-weight: 600;
    }

    .quick-action-subtitle {
        font-size: 0.65rem;
    }

    /* Days Tracker Mobile Portrait */
    .days-tracker {
        gap: 0.2rem;
        margin-bottom: 0.75rem;
    }

    .day-item {
        padding: 0.2rem;
        gap: 0.1rem;
    }

    .day-box {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.7rem;
        border-radius: 0.5rem;
        border-width: 1px;
    }

    .day-label {
        font-size: 0.6rem;
    }

    .day-num {
        font-size: 0.6rem;
    }

    .day-today {
        font-size: 0.6rem;
    }

    .day-missed {
        font-size: 0.9rem;
    }

    /* Modal untuk Mobile */
    .modal {
        padding: 0.25rem;
        align-items: flex-end;
        justify-content: stretch;
    }

    .modal.center-modal {
        align-items: center;
    }

    .modal-content {
        padding: 1.25rem 1rem;
        max-width: 100%;
        width: 100%;
        max-height: 90vh;
        border-radius: 1rem 1rem 0 0;
        overflow-y: auto;
    }

    .modal.center-modal .modal-content {
        border-radius: 1rem;
    }

    .modal-header {
        margin-bottom: 1rem;
        gap: 0.5rem;
    }

    .modal-title {
        font-size: 1.1rem;
        gap: 0.4rem;
    }

    .modal-title i {
        width: 20px !important;
        height: 20px !important;
    }

    .btn-close {
        padding: 0.4rem;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .btn-close i {
        width: 18px !important;
        height: 18px !important;
    }

    /* Auth Cards Mobile */
    .auth-container {
        padding: 0.5rem;
        min-height: auto;
    }

    .auth-card {
        padding: 1.25rem 1rem;
        max-width: 100%;
        width: 100%;
    }

    .auth-header {
        margin-bottom: 1.5rem;
    }

    .auth-logo {
        padding: 0.6rem;
        margin-bottom: 0.75rem;
    }

    .auth-logo i {
        width: 24px !important;
        height: 24px !important;
    }

    .auth-title {
        font-size: 1.3rem;
        margin-bottom: 0.3rem;
    }

    .auth-subtitle {
        font-size: 0.75rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .form-label {
        margin-bottom: 0.4rem;
        font-size: 0.8rem;
    }

    .form-input {
        padding: 0.6rem 0.75rem;
        font-size: 16px; /* Prevent zoom on iOS */
        border-radius: 0.6rem;
    }

    .form-error {
        font-size: 0.75rem;
        margin-top: 0.25rem;
    }

    .btn {
        padding: 0.65rem;
        font-size: 0.85rem;
        gap: 0.4rem;
        border-radius: 0.6rem;
    }

    .btn i {
        width: 18px !important;
        height: 18px !important;
    }

    .btn-google {
        margin-top: 0.75rem;
    }

    .divider {
        margin: 1rem 0;
        font-size: 0.8rem;
    }

    .divider span {
        padding: 0 0.75rem;
    }

    .auth-link {
        margin-top: 1rem;
        font-size: 0.8rem;
    }

    /* Insights Grid Mobile */
    .insights-grid {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }

    .insight-card {
        padding: 0.75rem;
    }

    .insight-value {
        font-size: 1.25rem;
    }

    .insight-label {
        font-size: 0.8rem;
        margin-top: 0.2rem;
    }

    .insight-detail {
        font-size: 0.7rem;
        margin-top: 0.3rem;
    }

    /* Analytics Section Mobile */
    .analytics-section {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        border-radius: 0.75rem;
    }

    .section-header {
        font-size: 1rem;
        margin-bottom: 0.75rem;
        gap: 0.4rem;
    }

    .section-title {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
        gap: 0.3rem;
    }

    /* Performance Trend Container Mobile */
    .performance-trend-container {
        height: 220px;
        padding: 0.75rem;
        border-radius: 0.75rem;
        margin-bottom: 1rem;
    }

    .performance-trend-container canvas {
        max-width: 100%;
    }

    /* Habit Performance Mobile */
    .habit-performance {
        margin-bottom: 1rem;
    }

    .performance-header {
        margin-bottom: 0.4rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .performance-rate {
        font-size: 0.8rem;
    }

    .progress-bar {
        height: 0.4rem;
        border-radius: 999px;
    }

    /* AI Coach - ekstra compact di layar kecil */
    .ai-coach-wrapper {
        padding: 0.75rem;
    }

    .ai-coach-header {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
        font-size: 0.95rem;
    }

    .ai-coach-body {
        gap: 0.4rem;
    }

    .ai-messages {
        max-height: 200px;
        padding: 0.4rem;
    }

    .ai-bubble {
        max-width: 92%;
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .ai-message-row {
        gap: 0.3rem;
    }

    .ai-input-row {
        gap: 0.3rem;
    }

    .ai-input {
        min-height: 32px;
        padding: 0.5rem 0.6rem;
        font-size: 14px; /* Prevent zoom on iOS */
        border-radius: 0.5rem;
    }

    .ai-input-row button {
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
        height: 32px;
    }

    .ai-input-row button i {
        width: 16px !important;
        height: 16px !important;
    }

    /* Notification Bar Mobile */
    #notificationBar {
        padding: 0.6rem !important;
        margin: 0.5rem 0 !important;
        border-radius: 0.6rem !important;
        gap: 0.6rem !important;
        font-size: 0.85rem;
    }

    #notificationBarText {
        font-size: 0.85rem;
    }

    /* Calendar Mobile */
    .calendar-container {
        padding: 0;
    }

    .calendar-header {
        padding: 0.75rem;
    }

    .calendar-grid {
        gap: 0.2rem;
    }

    .calendar-day {
        aspect-ratio: 1;
        font-size: 0.8rem;
    }

    .calendar-day-label {
        font-size: 0.65rem;
    }

    /* General Button Fixes */
    button:focus {
        outline: 2px solid #a855f7;
        outline-offset: 2px;
    }

    /* Touch-friendly spacing */
    @supports (padding: max(0px)) {
        .container {
            padding: max(0.5rem, env(safe-area-inset-left)) max(0.5rem, env(safe-area-inset-right));
        }

        .modal-content {
            padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
        }
    }

    /* Hide elements yang tidak penting di mobile */
    .hide-on-mobile {
        display: none !important;
    }
}