/* ============================================
   Habit Tracker CSS Styles
   Mobile-first responsive design with emerald/green theme
   Requirements: 9.1, 9.2, 9.4, 9.6, 9.7
   ============================================ */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --habit-primary: #10b981;
    --habit-primary-dark: #059669;
    --habit-primary-light: #d1fae5;
    --habit-secondary: #14b8a6;
    --habit-secondary-dark: #0d9488;
    --habit-gradient-start: #10b981;
    --habit-gradient-end: #14b8a6;
    --habit-success: #22c55e;
    --habit-warning: #f59e0b;
    --habit-error: #ef4444;
    --habit-text-primary: #1f2937;
    --habit-text-secondary: #6b7280;
    --habit-text-muted: #9ca3af;
    --habit-border: #e5e7eb;
    --habit-bg-card: #ffffff;
    --habit-bg-page: #f9fafb;
    --habit-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --habit-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --habit-radius: 1rem;
    --habit-radius-sm: 0.75rem;
    --habit-radius-lg: 1.5rem;
}

/* ============================================
   TASK 9.1: CHECK-IN MODAL STYLES
   Requirements: 9.1, 9.2, 9.4, 9.7
   ============================================ */

/* Modal Overlay */
#habit-check-in-modal {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Modal Container Animation */
#habit-check-in-modal .bg-white {
    animation: habit-modal-slide-up 0.3s ease-out;
}

@keyframes habit-modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Mood Selector Buttons */
.mood-btn {
    position: relative;
    transition: all 0.2s ease;
    min-width: 48px;
    min-height: 48px;
}

.mood-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.mood-btn:active {
    transform: translateY(0);
}

.mood-btn[aria-checked="true"] {
    border-color: var(--habit-primary) !important;
    background-color: var(--habit-primary-light) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.mood-btn[aria-checked="true"]::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background-color: var(--habit-primary);
    border-radius: 50%;
}

.mood-btn span {
    transition: transform 0.2s ease;
}

.mood-btn:hover span {
    transform: scale(1.15);
}

/* Habit Checkboxes */
.habit-checkbox {
    position: relative;
    transition: all 0.2s ease;
    min-height: 56px;
}

.habit-checkbox:hover {
    border-color: var(--habit-primary) !important;
    background-color: rgba(16, 185, 129, 0.05);
}

.habit-checkbox:has(input:checked) {
    border-color: var(--habit-primary) !important;
    background-color: var(--habit-primary-light) !important;
}

.habit-checkbox input[type="checkbox"] {
    accent-color: var(--habit-primary);
    cursor: pointer;
}

.habit-checkbox input[type="checkbox"]:focus {
    outline: 2px solid var(--habit-primary);
    outline-offset: 2px;
}

/* Custom checkbox styling */
.habit-checkbox input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--habit-border);
    border-radius: 6px;
    background-color: white;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
}

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

.habit-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Note Textarea */
#check-in-note {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#check-in-note:focus {
    border-color: var(--habit-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Voice Input Button */
#voice-input-btn {
    transition: all 0.2s ease;
}

#voice-input-btn:hover {
    transform: scale(1.1);
}

#voice-input-btn.animate-pulse {
    animation: voice-pulse 1.5s ease-in-out infinite;
}

@keyframes voice-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* Submit Button Gradient */
#check-in-submit {
    background: linear-gradient(135deg, var(--habit-gradient-start), var(--habit-gradient-end));
    transition: all 0.2s ease;
}

#check-in-submit:hover {
    background: linear-gradient(135deg, var(--habit-primary-dark), var(--habit-secondary-dark));
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

#check-in-submit:active {
    transform: translateY(0);
}

/* Error and Success Messages */
#check-in-error {
    animation: habit-shake 0.4s ease;
}

@keyframes habit-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

#check-in-success {
    animation: habit-success-pop 0.4s ease;
}

@keyframes habit-success-pop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}



/* ============================================
   TASK 9.2: DASHBOARD COMPONENT STYLES
   Requirements: 9.4, 9.6, 9.7
   ============================================ */

/* Dashboard Container */
.habit-dashboard {
    max-width: 100%;
    margin: 0 auto;
}

@media (min-width: 640px) {
    .habit-dashboard {
        max-width: 480px;
    }
}

@media (min-width: 768px) {
    .habit-dashboard {
        max-width: 560px;
    }
}

/* Streak Display Section */
.streak-section {
    position: relative;
    overflow: hidden;
}

.streak-section > div {
    position: relative;
}

/* Streak fire animation */
.streak-section .text-4xl {
    animation: streak-fire-glow 2s ease-in-out infinite;
}

@keyframes streak-fire-glow {
    0%, 100% {
        filter: drop-shadow(0 0 4px rgba(251, 146, 60, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(251, 146, 60, 0.8));
    }
}

/* Streak progress bar animation */
.streak-section .bg-white\/80 {
    transition: width 0.8s ease-out;
}

/* Quick Stats Grid */
.quick-stats-section .grid {
    gap: 0.75rem;
}

.quick-stats-section .bg-white {
    transition: all 0.2s ease;
}

.quick-stats-section .bg-white:hover {
    transform: translateY(-2px);
    box-shadow: var(--habit-shadow-lg);
}

/* Stat number animation */
.quick-stats-section .text-2xl {
    transition: transform 0.3s ease;
}

.quick-stats-section .bg-white:hover .text-2xl {
    transform: scale(1.05);
}

/* Weekly Grid Section */
.weekly-grid-section {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.weekly-grid-section table {
    min-width: 320px;
}

/* Grid cell styling */
.weekly-grid-section td .w-6 {
    transition: all 0.2s ease;
}

.weekly-grid-section td .bg-emerald-500 {
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.weekly-grid-section tr:hover td .w-6 {
    transform: scale(1.1);
}

/* Mood Graph Section */
.mood-graph-section svg {
    overflow: visible;
}

/* Graph line animation */
.mood-graph-section path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: mood-line-draw 1.5s ease forwards;
}

@keyframes mood-line-draw {
    to {
        stroke-dashoffset: 0;
    }
}

/* Graph data points */
.mood-graph-section circle {
    transition: all 0.2s ease;
    cursor: pointer;
}

.mood-graph-section circle:hover {
    r: 6;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Toggle buttons */
.mood-graph-section button {
    transition: all 0.2s ease;
}

.mood-graph-section button:hover:not(.bg-emerald-500) {
    background-color: #e5e7eb;
}

/* Calendar Section */
.calendar-section {
    position: relative;
}

/* Calendar day buttons */
.calendar-section button {
    transition: all 0.15s ease;
}

.calendar-section button:hover {
    background-color: rgba(16, 185, 129, 0.1);
}

.calendar-section button:active {
    transform: scale(0.95);
}

/* Mood dot indicator */
.calendar-section .w-2 {
    transition: transform 0.2s ease;
}

.calendar-section button:hover .w-2 {
    transform: scale(1.5);
}

/* Today highlight */
.calendar-section .ring-2 {
    animation: today-pulse 2s ease-in-out infinite;
}

@keyframes today-pulse {
    0%, 100% {
        box-shadow: 0 0 0 2px var(--habit-primary);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3);
    }
}

/* Calendar navigation buttons */
.calendar-section .flex.gap-2 button {
    transition: all 0.2s ease;
}

.calendar-section .flex.gap-2 button:hover {
    background-color: var(--habit-primary-light);
    color: var(--habit-primary-dark);
}

/* Date Detail Modal */
#date-detail-modal {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#date-detail-modal > div {
    animation: habit-modal-slide-up 0.3s ease-out;
}

/* Insights Panel Section */
.insights-section {
    position: relative;
}

/* Insight cards */
.insights-section .flex.items-start {
    transition: all 0.2s ease;
}

.insights-section .flex.items-start:hover {
    transform: translateX(4px);
}

/* Insight icon animation */
.insights-section .text-2xl {
    transition: transform 0.3s ease;
}

.insights-section .flex.items-start:hover .text-2xl {
    transform: scale(1.15) rotate(-5deg);
}

/* Progress bar for insights unlock */
.insights-section .bg-emerald-500.h-2 {
    transition: width 0.8s ease-out;
    background: linear-gradient(90deg, var(--habit-gradient-start), var(--habit-gradient-end));
}

/* Share Button Section */
.share-section button {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.share-section button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.share-section button:hover::before {
    left: 100%;
}

.share-section button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.share-section button:active {
    transform: translateY(0);
}



/* ============================================
   TASK 9.3: SETTINGS SCREEN STYLES
   Requirements: 9.2, 9.7
   ============================================ */

/* Settings Container */
.habit-settings {
    max-width: 100%;
    margin: 0 auto;
}

@media (min-width: 640px) {
    .habit-settings {
        max-width: 480px;
    }
}

@media (min-width: 768px) {
    .habit-settings {
        max-width: 560px;
    }
}

/* Settings Section Cards */
.habit-settings .bg-white {
    transition: all 0.2s ease;
}

.habit-settings .bg-white:hover {
    box-shadow: var(--habit-shadow-lg);
}

/* Toggle Switch Styling */
.habit-settings .peer {
    transition: background-color 0.2s ease;
}

.habit-settings .peer:focus + div {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

/* Toggle container hover effect */
.habit-settings .flex.items-center.justify-between {
    transition: all 0.2s ease;
}

.habit-settings .flex.items-center.justify-between:hover {
    background-color: rgba(16, 185, 129, 0.02);
}

/* Habit toggle rows */
.habit-settings .space-y-3 > div {
    transition: all 0.2s ease;
}

.habit-settings .space-y-3 > div:hover {
    transform: translateX(4px);
}

/* Habit icon animation */
.habit-settings .text-2xl {
    transition: transform 0.3s ease;
}

.habit-settings .space-y-3 > div:hover .text-2xl {
    transform: scale(1.15);
}

/* Time Picker Input */
#reminder-time-input {
    transition: all 0.2s ease;
}

#reminder-time-input:focus {
    border-color: var(--habit-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Update Time Button */
#update-time-btn {
    transition: all 0.2s ease;
}

#update-time-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

#update-time-btn:active {
    transform: translateY(0);
}

/* Data Management Buttons */
#export-data-btn,
#import-data-btn,
#clear-data-btn {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

#export-data-btn:hover,
#import-data-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

#clear-data-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

#export-data-btn:active,
#import-data-btn:active,
#clear-data-btn:active {
    transform: translateY(0);
}

/* Button icon animation */
#export-data-btn svg,
#import-data-btn svg,
#clear-data-btn svg {
    transition: transform 0.2s ease;
}

#export-data-btn:hover svg {
    transform: translateY(2px);
}

#import-data-btn:hover svg {
    transform: translateY(-2px);
}

#clear-data-btn:hover svg {
    transform: scale(1.1);
}

/* Confirmation Modal */
#settings-confirm-modal {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#settings-confirm-content {
    animation: habit-modal-slide-up 0.3s ease-out;
}

/* Confirmation buttons */
#confirm-cancel-btn,
#confirm-action-btn {
    transition: all 0.2s ease;
}

#confirm-cancel-btn:hover {
    background-color: #f3f4f6;
}

#confirm-action-btn:hover {
    transform: translateY(-1px);
}

/* Status Message Toast */
#settings-status-message {
    animation: toast-slide-up 0.3s ease-out;
}

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

#settings-status-message.hidden {
    animation: toast-slide-down 0.3s ease-out forwards;
}

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

/* ============================================
   RESPONSIVE ADJUSTMENTS
   Mobile-first approach
   ============================================ */

/* Extra small screens (< 375px) */
@media (max-width: 374px) {
    .mood-btn {
        min-width: 40px;
        padding: 0.5rem 0.25rem;
    }
    
    .mood-btn span {
        font-size: 1.25rem;
    }
    
    .habit-checkbox {
        padding: 0.5rem;
    }
    
    .habit-checkbox span:first-of-type {
        font-size: 1.25rem;
    }
    
    .habit-checkbox span:last-of-type {
        font-size: 0.75rem;
    }
    
    .quick-stats-section .text-2xl {
        font-size: 1.25rem;
    }
    
    .weekly-grid-section .text-sm {
        font-size: 0.7rem;
    }
}

/* Small screens (375px - 639px) */
@media (min-width: 375px) and (max-width: 639px) {
    .mood-btn {
        min-width: 44px;
    }
    
    .habit-checkbox {
        padding: 0.625rem;
    }
}

/* Medium screens (640px+) */
@media (min-width: 640px) {
    .mood-btn {
        min-width: 56px;
        padding: 1rem 0.75rem;
    }
    
    .mood-btn span {
        font-size: 2rem;
    }
    
    .habit-checkbox {
        padding: 1rem;
    }
    
    .habit-checkbox span:first-of-type {
        font-size: 1.75rem;
    }
    
    .quick-stats-section .grid {
        gap: 1rem;
    }
}

/* Large screens (768px+) */
@media (min-width: 768px) {
    .habit-dashboard,
    .habit-settings {
        padding: 1.5rem;
    }
    
    .mood-btn {
        min-width: 64px;
    }
    
    .weekly-grid-section table {
        min-width: 400px;
    }
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* Focus visible states */
.mood-btn:focus-visible,
.habit-checkbox:focus-within,
#check-in-submit:focus-visible,
#check-in-cancel:focus-visible {
    outline: 2px solid var(--habit-primary);
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .mood-btn,
    .habit-checkbox,
    .streak-section .text-4xl,
    .mood-graph-section path,
    .mood-graph-section circle,
    .calendar-section .ring-2,
    .share-section button::before,
    #settings-status-message,
    #habit-check-in-modal .bg-white,
    #date-detail-modal > div,
    #settings-confirm-content {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --habit-primary: #047857;
        --habit-primary-dark: #065f46;
        --habit-border: #374151;
    }
    
    .mood-btn,
    .habit-checkbox {
        border-width: 3px;
    }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    /* Placeholder for dark mode styles */
    /* Can be enabled when app supports dark mode */
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Fade in animation */
.animate-fade-in {
    animation: habit-fade-in 0.3s ease-out;
}

@keyframes habit-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Slide up animation */
.animate-slide-up {
    animation: habit-modal-slide-up 0.3s ease-out;
}

/* Bounce animation for celebrations */
.animate-bounce-once {
    animation: habit-bounce 0.5s ease;
}

@keyframes habit-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Spin animation for loading states */
.animate-spin-slow {
    animation: habit-spin 2s linear infinite;
}

@keyframes habit-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Gradient text effect */
.gradient-text {
    background: linear-gradient(135deg, var(--habit-gradient-start), var(--habit-gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Card hover lift effect */
.card-hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--habit-shadow-lg);
}

/* Emerald glow effect */
.emerald-glow {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

/* Scrollbar styling for habit components */
.habit-dashboard::-webkit-scrollbar,
.habit-settings::-webkit-scrollbar {
    width: 6px;
}

.habit-dashboard::-webkit-scrollbar-track,
.habit-settings::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.habit-dashboard::-webkit-scrollbar-thumb,
.habit-settings::-webkit-scrollbar-thumb {
    background: var(--habit-primary);
    border-radius: 3px;
}

.habit-dashboard::-webkit-scrollbar-thumb:hover,
.habit-settings::-webkit-scrollbar-thumb:hover {
    background: var(--habit-primary-dark);
}
