/* MoodMash Custom Styles */

/* Root variables for theming */
:root {
    --bg-primary: #f9fafb;
    --bg-secondary: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
}

/* Dark mode variables */
.dark {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --border-color: #374151;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* Apply theme variables */
body {
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Emotion color coding */
.emotion-happy {
    color: #fbbf24;
    background-color: #fef3c7;
}

.emotion-sad {
    color: #3b82f6;
    background-color: #dbeafe;
}

.emotion-anxious {
    color: #ef4444;
    background-color: #fee2e2;
}

.emotion-calm {
    color: #10b981;
    background-color: #d1fae5;
}

.emotion-energetic {
    color: #f59e0b;
    background-color: #fed7aa;
}

.emotion-tired {
    color: #6b7280;
    background-color: #f3f4f6;
}

.emotion-angry {
    color: #dc2626;
    background-color: #fecaca;
}

.emotion-peaceful {
    color: #8b5cf6;
    background-color: #ede9fe;
}

.emotion-stressed {
    color: #ef4444;
    background-color: #fee2e2;
}

.emotion-neutral {
    color: #64748b;
    background-color: #f1f5f9;
}

/* Intensity indicators */
.intensity-1 { opacity: 0.3; }
.intensity-2 { opacity: 0.5; }
.intensity-3 { opacity: 0.7; }
.intensity-4 { opacity: 0.85; }
.intensity-5 { opacity: 1.0; }

/* Smooth transitions */
.transition-all {
    transition: all 0.3s ease;
}

/* Card hover effect */
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Loading spinner animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Fade in animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* Emotion selector button */
.emotion-btn {
    transition: all 0.2s ease;
}

.emotion-btn:hover {
    transform: scale(1.05);
}

.emotion-btn.selected {
    ring: 2px;
    ring-offset: 2px;
}

/* Activity card */
.activity-card {
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.activity-card:hover {
    border-color: #6366f1;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.15);
}

/* Responsive chart container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

@media (min-width: 768px) {
    .chart-container {
        height: 400px;
    }
}

/* Dark mode adjustments */
.dark .bg-white {
    background-color: var(--bg-secondary) !important;
}

.dark .bg-gray-50,
.dark .bg-gray-100 {
    background-color: #374151 !important;
}

.dark .text-gray-800,
.dark .text-gray-700 {
    color: var(--text-primary) !important;
}

.dark .text-gray-600,
.dark .text-gray-500 {
    color: var(--text-secondary) !important;
}

.dark .border-gray-200,
.dark .border-gray-300 {
    border-color: var(--border-color) !important;
}

.dark .shadow-md,
.dark .shadow-lg {
    box-shadow: 0 4px 6px -1px var(--shadow);
}

/* Theme toggle button */
.theme-toggle {
    position: relative;
    width: 60px;
    height: 30px;
    background: #e5e7eb;
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.dark .theme-toggle {
    background: #4b5563;
}

.theme-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.dark .theme-toggle-thumb {
    transform: translateX(30px);
}

/* PWA install prompt */
.pwa-install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    max-width: 90%;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* iOS safe area support */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

/* Language selector */
.language-selector {
    position: relative;
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px var(--shadow);
    min-width: 150px;
    z-index: 50;
}

.language-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.language-option:hover {
    background: var(--bg-primary);
}

.language-option.active {
    background: #6366f1;
    color: white;
}

/* Loading skeleton for PWA */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* RTL (Right-to-Left) support for Arabic and other RTL languages */
[dir="rtl"] {
    text-align: right;
}

/* Flip margins and padding for RTL */
[dir="rtl"] .mr-1 { margin-right: 0; margin-left: 0.25rem; }
[dir="rtl"] .mr-2 { margin-right: 0; margin-left: 0.5rem; }
[dir="rtl"] .mr-3 { margin-right: 0; margin-left: 0.75rem; }
[dir="rtl"] .mr-4 { margin-right: 0; margin-left: 1rem; }

[dir="rtl"] .ml-1 { margin-left: 0; margin-right: 0.25rem; }
[dir="rtl"] .ml-2 { margin-left: 0; margin-right: 0.5rem; }
[dir="rtl"] .ml-3 { margin-left: 0; margin-right: 0.75rem; }
[dir="rtl"] .ml-4 { margin-left: 0; margin-right: 1rem; }

/* Flip padding for RTL */
[dir="rtl"] .pr-2 { padding-right: 0; padding-left: 0.5rem; }
[dir="rtl"] .pr-4 { padding-right: 0; padding-left: 1rem; }
[dir="rtl"] .pr-6 { padding-right: 0; padding-left: 1.5rem; }

[dir="rtl"] .pl-2 { padding-left: 0; padding-right: 0.5rem; }
[dir="rtl"] .pl-4 { padding-left: 0; padding-right: 1rem; }
[dir="rtl"] .pl-6 { padding-left: 0; padding-right: 1.5rem; }

/* Flip left and right positioning */
[dir="rtl"] .left-0 { left: auto; right: 0; }
[dir="rtl"] .right-0 { right: auto; left: 0; }

/* Flip text alignment */
[dir="rtl"] .text-left { text-align: right; }
[dir="rtl"] .text-right { text-align: left; }

/* Language dropdown position for RTL */
[dir="rtl"] .language-dropdown {
    right: auto;
    left: 0;
}

/* Theme toggle for RTL */
[dir="rtl"] .theme-toggle-thumb {
    left: auto;
    right: 3px;
}

[dir="rtl"] .dark .theme-toggle-thumb {
    transform: translateX(-30px);
}

/* Flex direction adjustments for RTL */
[dir="rtl"] .flex-row {
    flex-direction: row-reverse;
}

/* Accessibility Features */

/* Font Size Adjustments */
html.font-small {
    font-size: 14px;
}

html.font-normal {
    font-size: 16px;
}

html.font-large {
    font-size: 18px;
}

/* High Contrast Mode */
html.high-contrast {
    filter: contrast(1.3);
}

html.high-contrast .bg-white {
    background-color: #ffffff !important;
}

html.high-contrast .text-gray-600,
html.high-contrast .text-gray-500 {
    color: #000000 !important;
}

html.high-contrast button,
html.high-contrast a {
    outline: 2px solid #000;
    outline-offset: 2px;
}

/* Keyboard Navigation Focus */
body.keyboard-nav *:focus {
    outline: 3px solid #6366f1;
    outline-offset: 2px;
}

/* Onboarding Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Chatbot Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slideInUp {
    animation: slideInUp 0.3s ease-out;
}

/* Chatbot message bubble animations */
#chatbot-messages > div {
    animation: fadeIn 0.3s ease-out;
}

/* Floating button pulse animation */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

#chatbot-toggle:hover,
#accessibility-toggle:hover {
    animation: pulse 1s infinite;
}

/* Skip to main content link for screen readers */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #6366f1;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-main:focus {
    top: 0;
}

/* ARIA live region styling */
[aria-live] {
    position: relative;
}

/* Premium badge styling */
.premium-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Express Your Mood Styles */
.mode-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: #9ca3af;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    background: transparent;
}

.mode-tab:hover {
    color: #e5e7eb;
    background: rgba(255, 255, 255, 0.05);
}

.mode-tab.active {
    background: #6366f1;
    color: white;
}

.emoji-btn {
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.emoji-btn:hover {
    transform: scale(1.1);
    background: #f3f4f6 !important;
}

.emoji-btn.selected {
    background: #ede9fe !important;
    border-color: #6366f1 !important;
}

.color-btn {
    display: flex;
    align-items: center;
    justify-center;
    cursor: pointer;
    border: 3px solid transparent;
}

.recording-pulse {
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    animation: recordingPulse 1.5s ease-in-out infinite;
}

@keyframes recordingPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* Custom range input styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 3px solid #6366f1;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 3px solid #6366f1;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 16px;
    border-radius: 8px;
}

input[type="range"]::-moz-range-track {
    height: 16px;
    border-radius: 8px;
}

/* Quick Select Styles */
.quick-select-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.quick-select-content {
    background: white;
    border-radius: 1.5rem;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideInUp 0.3s ease;
}

.dark .quick-select-content {
    background: #1f2937;
}

.recent-emoji {
    font-size: 3rem;
    padding: 1rem;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f3f4f6;
}

.recent-emoji:hover {
    transform: scale(1.15);
    background: #e5e7eb;
}

.dark .recent-emoji {
    background: #374151;
}

.dark .recent-emoji:hover {
    background: #4b5563;
}

/* Insights Dashboard Styles */
.insight-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 1.5rem;
    padding: 2rem;
    color: white;
    position: relative;
    overflow: hidden;
}

.insight-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.1), transparent);
    pointer-events: none;
}

.metric-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
}

.metric-card:hover {
    border-color: #6366f1;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.15);
}

.dark .metric-card {
    background: #1f2937;
    border-color: #374151;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-circle {
    transition: stroke-dashoffset 0.35s;
    transform-origin: 50% 50%;
}

/* Timeline Styles */
.timeline-entry {
    position: relative;
    padding-left: 2rem;
    padding-bottom: 1.5rem;
}

.timeline-entry::before {
    content: '';
    position: absolute;
    left: 0.375rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e5e7eb;
}

.dark .timeline-entry::before {
    background: #374151;
}

.timeline-dot {
    position: absolute;
    left: 0;
    top: 0.25rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: #6366f1;
    border: 3px solid white;
    z-index: 1;
}

.dark .timeline-dot {
    border-color: #1f2937;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .mode-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .emoji-btn {
        font-size: 1.5rem;
    }
    
    .quick-select-content {
        width: 95%;
        padding: 1.5rem;
    }
    
    .recent-emoji {
        font-size: 2rem;
        padding: 0.75rem;
    }
}
