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

:root {
    --primary-dark: #393E46;
    --secondary-dark: #222831;
    --accent-cyan: #00ADB5;
    --light-gray: #EEEEEE;
    --accent-yellow: #FFD369;
    
    --border-radius: 16px;
    --border-radius-small: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --font-primary: 'Fredoka One', cursive;
    --font-secondary: 'Nunito', sans-serif;
}

body {
    font-family: var(--font-secondary);
    background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--primary-dark) 100%);
    min-height: 100vh;
    color: var(--primary-dark);
    overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--light-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}

.loading-content {
    text-align: center;
    color: var(--primary-dark);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--light-gray);
    border-top: 4px solid var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* App Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--light-gray);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--accent-yellow) 0%, #FFE066 100%);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.app-title {
    font-family: var(--font-primary);
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    color: var(--primary-dark);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.user-stats {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.stat-item {
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 15px;
    border-radius: var(--border-radius-small);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.stat-icon {
    font-size: 1.2em;
}

.stat-value {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 1.1em;
}

.parent-btn {
    background: var(--accent-cyan);
    border: none;
    padding: 12px;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.parent-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-hover);
}

/* Navigation */
.main-nav {
    background: var(--primary-dark);
    display: flex;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.nav-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 15px 10px;
    color: var(--light-gray);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    position: relative;
    overflow: hidden;
}

.nav-btn::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: var(--accent-yellow);
    transition: var(--transition);
    transform: translateX(-50%);
}

.nav-btn.active::before {
    width: 80%;
}

.nav-btn.active {
    background: rgba(255, 211, 105, 0.1);
    color: var(--accent-yellow);
}

.nav-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
}

.nav-icon {
    font-size: 1.5em;
}

.nav-text {
    font-size: 0.9em;
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px;
    position: relative;
}

.content-section {
    display: none;
    animation: fadeIn 0.5s ease-out;
}

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

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

.section-header {
    text-align: center;
    margin-bottom: 30px;
}

.section-header h2 {
    font-family: var(--font-primary);
    font-size: 2rem;
    color: var(--primary-dark);
    margin-bottom: 10px;
}

.section-header p {
    color: var(--primary-dark);
    opacity: 0.8;
    font-size: 1.1em;
}

/* Progress Bar */
.progress-bar {
    background: rgba(255, 255, 255, 0.5);
    height: 12px;
    border-radius: 6px;
    margin-top: 15px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-yellow));
    width: 0%;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
}

/* Tasks Container */
.tasks-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

.task-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border: 3px solid transparent;
}

.task-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-yellow));
}

.task-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent-cyan);
}

.task-card.completed {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #28a745;
}

.task-card.completed::before {
    background: #28a745;
}

.task-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 15px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-title {
    font-family: var(--font-primary);
    font-size: 1.3rem;
    color: var(--primary-dark);
    text-align: center;
    margin-bottom: 10px;
}

.task-description {
    color: var(--primary-dark);
    opacity: 0.8;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 15px;
}

.task-rewards {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.reward-item {
    background: var(--light-gray);
    padding: 5px 12px;
    border-radius: var(--border-radius-small);
    font-weight: 600;
    font-size: 0.9rem;
}

.task-status {
    text-align: center;
    font-weight: 700;
    padding: 8px;
    border-radius: var(--border-radius-small);
    margin-top: 10px;
}

.task-status.pending {
    background: rgba(255, 211, 105, 0.2);
    color: #856404;
}

.task-status.completed {
    background: rgba(40, 167, 69, 0.2);
    color: #155724;
}

/* Rewards Container */
.rewards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

.reward-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.reward-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-yellow), #FFE066);
}

.reward-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.reward-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.reward-title {
    font-family: var(--font-primary);
    font-size: 1.2rem;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.reward-cost {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.cost-item {
    background: var(--light-gray);
    padding: 4px 10px;
    border-radius: var(--border-radius-small);
    font-weight: 600;
    font-size: 0.9rem;
}

.buy-btn {
    background: var(--accent-cyan);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius-small);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.buy-btn:hover:not(:disabled) {
    background: #009aa2;
    transform: translateY(-2px);
}

.buy-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Achievements Container */
.achievements-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

.achievement-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.achievement-card.unlocked {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid var(--accent-yellow);
}

.achievement-card.unlocked::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent-yellow);
}

.achievement-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.achievement-icon {
    font-size: 2rem;
    opacity: 0.5;
}

.achievement-card.unlocked .achievement-icon {
    opacity: 1;
}

.achievement-title {
    font-family: var(--font-primary);
    font-size: 1.2rem;
    color: var(--primary-dark);
}

.achievement-description {
    color: var(--primary-dark);
    opacity: 0.8;
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 10px;
}

.achievement-progress {
    background: rgba(0, 0, 0, 0.1);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

.achievement-progress-fill {
    height: 100%;
    background: var(--accent-cyan);
    transition: width 0.5s ease;
    border-radius: 4px;
}

.achievement-stats {
    font-size: 0.85rem;
    color: var(--primary-dark);
    opacity: 0.8;
    text-align: right;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px) scale(0.9); }
    to { transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 20px 25px 10px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-family: var(--font-primary);
    font-size: 1.5rem;
    color: var(--primary-dark);
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--primary-dark);
    opacity: 0.7;
    transition: var(--transition);
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

.modal-body {
    padding: 25px;
}

/* Task Modal */
.task-modal-content {
    width: 90%;
    max-width: 500px;
}

.task-modal-icon {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 20px;
}

.task-modal-title {
    font-family: var(--font-primary);
    font-size: 1.8rem;
    color: var(--primary-dark);
    text-align: center;
    margin-bottom: 15px;
}

.task-modal-description {
    color: var(--primary-dark);
    opacity: 0.8;
    text-align: center;
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 20px;
}

.task-media {
    text-align: center;
    margin-bottom: 20px;
}

.task-media audio,
.task-media video {
    max-width: 100%;
    border-radius: var(--border-radius-small);
}

.task-rewards {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
}

.task-rewards .reward-item {
    background: var(--light-gray);
    padding: 10px 20px;
    border-radius: var(--border-radius-small);
    font-weight: 700;
    font-size: 1.1rem;
}

.btn-complete {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: var(--border-radius);
    font-family: var(--font-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    box-shadow: var(--shadow);
}

.btn-complete:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Celebration Modal */
.celebration-modal .modal-content {
    width: 90%;
    max-width: 400px;
    text-align: center;
    background: linear-gradient(135deg, var(--accent-yellow) 0%, #FFE066 100%);
}

.celebration-content {
    padding: 40px 30px;
}

.celebration-animation {
    animation: celebrationBounce 0.6s ease-out;
}

@keyframes celebrationBounce {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.celebration-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: rotate 2s linear infinite;
}

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

.celebration-content h2 {
    font-family: var(--font-primary);
    font-size: 2.2rem;
    color: var(--primary-dark);
    margin-bottom: 15px;
}

.celebration-content p {
    font-size: 1.2rem;
    color: var(--primary-dark);
    margin-bottom: 20px;
}

.earned-rewards {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
}

.earned-reward {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-weight: 700;
    font-size: 1.2rem;
    box-shadow: var(--shadow);
}

/* Parent Modal */
.parent-tabs {
    display: flex;
    border-bottom: 2px solid var(--light-gray);
    margin-bottom: 20px;
}

.parent-tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 12px 15px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    color: var(--primary-dark);
    border-bottom: 3px solid transparent;
}

.parent-tab-btn.active {
    border-bottom-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.parent-tab-btn:hover:not(.active) {
    background: rgba(0, 0, 0, 0.05);
}

.parent-tab-content {
    display: none;
}

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

/* Form Styles */
.add-task-form {
    background: var(--light-gray);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
}

.add-task-form h4 {
    font-family: var(--font-primary);
    color: var(--primary-dark);
    margin-bottom: 15px;
}

.add-task-form input,
.add-task-form textarea,
.add-task-form select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius-small);
    font-family: var(--font-secondary);
    font-size: 1rem;
    margin-bottom: 15px;
    transition: var(--transition);
}

.add-task-form input:focus,
.add-task-form textarea:focus,
.add-task-form select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 173, 181, 0.1);
}

.add-task-form textarea {
    resize: vertical;
    min-height: 80px;
}

.reward-settings {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.reward-settings label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.reward-settings input {
    margin: 0;
    width: 80px;
}

/* Button Styles */
.btn-primary {
    background: var(--accent-cyan);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: var(--border-radius-small);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.btn-primary:hover {
    background: #009aa2;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--primary-dark);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: var(--border-radius-small);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.btn-secondary:hover {
    background: #2c3139;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: var(--border-radius-small);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Settings */
.settings-group {
    margin-bottom: 25px;
}

.settings-group h4 {
    font-family: var(--font-primary);
    color: var(--primary-dark);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 5px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    cursor: pointer;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-cyan);
}

.setting-item input[type="number"] {
    width: 100px;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius-small);
}

/* Progress Stats */
.progress-stats {
    background: var(--light-gray);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

.weekly-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.stat-card {
    background: white;
    padding: 15px;
    border-radius: var(--border-radius-small);
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stat-card h5 {
    color: var(--primary-dark);
    margin-bottom: 5px;
    font-size: 0.9rem;
    opacity: 0.8;
}

.stat-card .stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

/* Daily Progress Chart */
.daily-progress-chart {
    display: flex;
    align-items: end;
    gap: 10px;
    height: 200px;
    padding: 20px;
    background: var(--light-gray);
    border-radius: var(--border-radius);
}

.chart-bar {
    flex: 1;
    background: var(--accent-cyan);
    border-radius: 4px 4px 0 0;
    min-height: 20px;
    position: relative;
    transition: var(--transition);
}

.chart-bar:hover {
    background: #009aa2;
}

.chart-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: var(--primary-dark);
    opacity: 0.8;
}

/* Footer */
.app-footer {
    background: var(--secondary-dark);
    color: var(--light-gray);
    text-align: center;
    padding: 15px 20px;
    font-size: 0.9rem;
    margin-top: auto;
}

.app-footer a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: var(--transition);
}

.app-footer a:hover {
    color: var(--accent-yellow);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-title {
        font-size: 1.8rem;
    }
    
    .user-stats {
        justify-content: center;
        width: 100%;
    }
    
    .header-content {
        justify-content: center;
        text-align: center;
    }
    
    .parent-btn {
        position: absolute;
        top: 20px;
        right: 20px;
    }
    
    .tasks-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .rewards-container {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .achievements-container {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        max-width: 95%;
        margin: 10px;
    }
    
    .parent-tabs {
        flex-direction: column;
    }
    
    .parent-tab-btn {
        border-bottom: none;
        border-left: 3px solid transparent;
    }
    
    .parent-tab-btn.active {
        border-left-color: var(--accent-cyan);
        border-bottom-color: transparent;
    }
    
    .reward-settings {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-text {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 15px;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .task-card {
        padding: 20px;
    }
    
    .task-icon {
        font-size: 2.5rem;
    }
    
    .task-title {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .celebration-content {
        padding: 30px 20px;
    }
    
    .nav-icon {
        font-size: 1.2em;
    }
    
    .nav-text {
        font-size: 0.75rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 3px solid var(--accent-cyan);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.4);
    }
    
    .task-card,
    .reward-card,
    .achievement-card {
        border: 2px solid var(--primary-dark);
    }
}

/* Print styles */
@media print {
    .app-header,
    .main-nav,
    .modal,
    .app-footer {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    .task-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
}
