/* ABLE Affirmations App Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 50%, #1B5E20 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    position: relative;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
}

/* Screen Management - FIXED */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
    z-index: 1;
    background: transparent;
    padding: 1rem;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    z-index: 2;
}

/* Welcome Screen - HIDDEN by default */
#welcome-screen {
    display: none;
}

#welcome-screen.active {
    display: flex;
}

.welcome-content {
    text-align: center;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(15px);
    max-width: 600px;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.welcome-image {
    width: 100%;
    max-width: 500px;
    height: auto;
    border-radius: 15px;
    margin-bottom: 2rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.welcome-content h1,
.welcome-content h2,
.welcome-content p {
    color: #333;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    font-weight: 600;
}

/* Affirmation Screen */
.affirmation-content {
    padding: 1.5rem 1rem;
    text-align: center;
    width: 100%;
    max-width: 700px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    margin: 0 auto;
    margin-bottom: 100px; /* Space for navigation */
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.category-filter {
    margin-bottom: 1.5rem;
}

.category-filter label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
}

.category-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
    color: #333;
}

.category-select:focus {
    outline: none;
    border-color: #4CAF50;
}

.affirmation-image {
    width: 100%;
    max-width: 500px;
    height: auto;
    border-radius: 15px;
    margin-bottom: 1rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.affirmation-info {
    margin-bottom: 1.5rem;
}

.category-badge {
    display: inline-block;
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.tag {
    background: rgba(76, 175, 80, 0.1);
    color: #2E7D32;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

/* Favorites Screen */
.favorites-content {
    padding: 2rem 1rem;
    width: 100%;
    max-width: 800px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    margin: 0 auto;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.favorites-content h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: #333;
    font-size: 1.8rem;
    font-weight: 700;
}

.favorites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.favorite-item {
    position: relative;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.favorite-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.favorite-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.remove-favorite {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.remove-favorite:hover {
    background: rgba(255, 0, 0, 1);
}

/* Buttons */
.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-width: 150px;
}

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

.btn-primary {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    color: white;
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #66BB6A, #4CAF50);
    color: white;
    box-shadow: 0 5px 15px rgba(102, 187, 106, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 187, 106, 0.4);
}

.btn-accent {
    background: linear-gradient(135deg, #81C784, #66BB6A);
    color: white;
    box-shadow: 0 5px 15px rgba(129, 199, 132, 0.3);
}

.btn-accent:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(129, 199, 132, 0.4);
}

.btn-share {
    background: linear-gradient(135deg, #66BB6A, #4CAF50);
    color: white;
    box-shadow: 0 5px 15px rgba(102, 187, 106, 0.3);
}

.btn-share:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 187, 106, 0.4);
}

.btn-reflect {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    color: white;
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-reflect::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;
}

.btn-reflect:hover::before {
    left: 100%;
}

.btn-reflect:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4);
}

.btn-ghost {
    background: transparent;
    color: #4CAF50;
    border: 1px solid #4CAF50;
    box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(76, 175, 80, 0.1);
    transform: translateY(-1px);
}

/* Navigation */
.nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 100;
}

.nav-btn {
    background: transparent;
    border: 2px solid #4CAF50;
    color: #4CAF50;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 0.5rem;
    min-width: 100px;
}

.nav-btn:hover,
.nav-btn.active {
    background: #4CAF50;
    color: white;
    transform: translateY(-2px);
}

/* Modal Styles - CRITICAL FIX */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* CRITICAL: Properly hide modal when not in use */
.modal.hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    z-index: 1001;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Reflection Styles */
.reflection-header {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.reflection-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
}

.reflection-settings {
    flex: 1;
}

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

.setting-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

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

.toggle-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.toggle-btn.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.toggle-btn:hover:not(.active) {
    border-color: #4CAF50;
    color: #4CAF50;
}

.prompt-section {
    margin-bottom: 2rem;
}

.prompt-text {
    background: rgba(76, 175, 80, 0.1);
    padding: 1rem;
    border-radius: 10px;
    border-left: 4px solid #4CAF50;
    font-style: italic;
    margin-bottom: 1rem;
}

.prompt-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.journal-section textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
}

.journal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* Tabs */
.favorites-tabs {
    display: flex;
    margin-bottom: 2rem;
    border-bottom: 1px solid #eee;
}

.tab-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: #4CAF50;
    border-bottom-color: #4CAF50;
}

.tab-btn:hover:not(.active) {
    color: #333;
}

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

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    left: -10000px !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #4CAF50;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .screen {
        padding: 0.5rem;
    }
    
    .welcome-content,
    .affirmation-content,
    .favorites-content {
        margin: 0;
        padding: 1rem;
        max-width: 100%;
    }
    
    .affirmation-content {
        margin-bottom: 80px;
        max-height: calc(100vh - 100px);
    }
    
    .welcome-image {
        max-width: 350px;
    }
    
    .affirmation-image {
        max-width: 400px;
    }
    
    .controls {
        gap: 0.6rem;
    }
    
    .btn {
        padding: 0.7rem 1.2rem;
        font-size: 0.9rem;
        min-width: 120px;
    }
    
    .favorites-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 0.8rem;
    }
    
    .nav {
        padding: 0.8rem;
    }
    
    .nav-btn {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
        min-width: 80px;
        margin: 0 0.3rem;
    }
    
    .modal-content {
        padding: 1.5rem;
        margin: 0.5rem;
    }
    
    .reflection-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .reflection-image {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 480px) {
    .screen {
        padding: 0.25rem;
    }
    
    .welcome-content,
    .affirmation-content,
    .favorites-content {
        padding: 0.8rem;
    }
    
    .affirmation-content {
        margin-bottom: 70px;
        max-height: calc(100vh - 90px);
    }
    
    .welcome-image {
        max-width: 280px;
    }
    
    .affirmation-image {
        max-width: 320px;
    }
    
    .controls {
        gap: 0.5rem;
    }
    
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        min-width: 100px;
    }
    
    .favorites-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .nav {
        padding: 0.6rem;
    }
    
    .nav-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.75rem;
        min-width: 70px;
        margin: 0 0.2rem;
    }
}

/* Dark Mode Support */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --accent-color: #66BB6A;
    --border-color: #404040;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, #0d0d0d 100%);
    color: var(--text-primary);
}

[data-theme="dark"] .welcome-content,
[data-theme="dark"] .affirmation-content,
[data-theme="dark"] .favorites-content,
[data-theme="dark"] .modal-content {
    background: rgba(45, 45, 45, 0.95);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .nav {
    background: rgba(45, 45, 45, 0.95);
    border-top: 1px solid var(--border-color);
}

[data-theme="dark"] .nav-btn {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

[data-theme="dark"] .nav-btn:hover,
[data-theme="dark"] .nav-btn.active {
    background: var(--accent-color);
    color: white;
}

/* FIXED: Dark mode category filter - make label and select bright and readable */
[data-theme="dark"] .category-filter label {
    color: #ffffff !important;
    font-weight: 700 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8) !important;
}

[data-theme="dark"] .category-select {
    background: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: #ffffff !important;
    font-weight: 500;
}

[data-theme="dark"] .category-select:focus {
    border-color: var(--accent-color) !important;
    background: var(--bg-secondary) !important;
    color: #ffffff !important;
}

/* Dark mode option text styling */
[data-theme="dark"] .category-select option {
    background: var(--bg-secondary) !important;
    color: #ffffff !important;
    font-weight: 500;
}

[data-theme="dark"] .tag {
    background: rgba(102, 187, 106, 0.2);
    color: var(--accent-color);
    border: 1px solid rgba(102, 187, 106, 0.3);
}

[data-theme="dark"] .favorite-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .reflection-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .toggle-btn {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .toggle-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

[data-theme="dark"] .toggle-btn:hover:not(.active) {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

[data-theme="dark"] #reflection-text {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] #reflection-text:focus {
    border-color: var(--accent-color);
}

[data-theme="dark"] #reflection-text::placeholder {
    color: var(--text-secondary);
}

[data-theme="dark"] .prompt-text {
    background: rgba(102, 187, 106, 0.1);
    border-left-color: var(--accent-color);
    color: var(--text-primary);
}

[data-theme="dark"] .tab-btn {
    color: var(--text-secondary);
}

[data-theme="dark"] .tab-btn.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

[data-theme="dark"] .tab-btn:hover:not(.active) {
    color: var(--text-primary);
}

[data-theme="dark"] .close-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

[data-theme="dark"] .close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .setting-label {
    color: var(--text-primary);
}

/* Theme Toggle Button */
.theme-toggle {
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    background: rgba(76, 175, 80, 0.1);
    transform: translateY(-2px) scale(1.05);
}

.theme-toggle:active {
    transform: scale(0.95);
}

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

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

/* Touch and Interaction Feedback */
.btn:active,
.nav-btn:active,
.favorite-item:active {
    transform: scale(0.98);
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Focus States for Accessibility */
.btn:focus,
.nav-btn:focus,
.category-select:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .screen {
        background: white;
        color: black;
    }
    
    .category-badge {
        background: black;
        color: white;
    }
    
    .tag {
        background: white;
        color: black;
        border: 1px solid black;
    }
}

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

/* Widget Container */
.widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border-radius: 15px;
    padding: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 300px;
    z-index: 999;
}

.widget-container.hidden {
    display: none !important;
}

.widget-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.widget-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.widget-affirmation {
    margin-bottom: 1rem;
}

.widget-affirmation-img {
    width: 100%;
    border-radius: 10px;
    margin-bottom: 0.5rem;
}

.widget-actions {
    display: flex;
    gap: 0.5rem;
}

.widget-btn {
    flex: 1;
    padding: 0.5rem;
    border: none;
    border-radius: 8px;
    background: #4CAF50;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.widget-btn:hover {
    background: #2E7D32;
    transform: translateY(-1px);
}

.reflections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.reflection-item {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.reflection-body {
    margin-top: 2rem;
}

.reflection-body h3 {
    margin-bottom: 1rem;
    color: #333;
}

[data-theme="dark"] .reflection-body h3 {
    color: var(--text-primary);
}
