/* Worshipful Master Study Application - Main Stylesheet */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* Dark Mode */
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #94a3b8;
    --success-color: #22c55e;
    --warning-color: #fbbf24;
    --danger-color: #f87171;
    --background: #0f172a;
    --surface: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
}

.logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

.main-nav {
    display: flex;
    gap: 1.5rem;
}

.main-nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.countdown-mini {
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.875rem;
}

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

/* User Menu Dropdown */
.user-menu {
    position: relative;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.user-menu-toggle:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.user-menu-toggle .user-icon {
    font-size: 1rem;
}

.user-menu-toggle .username {
    font-weight: 600;
}

.user-menu-toggle .dropdown-arrow {
    font-size: 0.625rem;
    transition: transform 0.2s;
}

.user-menu-toggle:hover .dropdown-arrow {
    transform: translateY(2px);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 240px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 0.75rem 0.75rem 0 0;
}

.dropdown-user-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 1.25rem;
}

.dropdown-user-info {
    flex: 1;
}

.dropdown-username {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.dropdown-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
}

.dropdown-item:hover {
    background: var(--background);
    color: var(--primary-color);
}

.dropdown-item .item-icon {
    font-size: 1.125rem;
    width: 20px;
    text-align: center;
}

.dropdown-item.logout-item {
    color: var(--danger-color);
    border-radius: 0 0 0.75rem 0.75rem;
}

.dropdown-item.logout-item:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Main Content */
main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

/* Alert Messages */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid;
}

.alert-success {
    background: #d1fae5;
    border-color: var(--success-color);
    color: #065f46;
}

.alert-error {
    background: #fee2e2;
    border-color: var(--danger-color);
    color: #991b1b;
}

.alert-info {
    background: #dbeafe;
    border-color: var(--primary-color);
    color: #1e40af;
}

/* Dashboard */
.exam-countdown {
    margin-bottom: 2rem;
}

.countdown-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.countdown-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.countdown-number {
    font-size: 4rem;
    font-weight: 800;
    margin: 1rem 0;
}

.countdown-label {
    font-size: 1.25rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.9;
}

.countdown-date {
    margin-top: 1rem;
    opacity: 0.8;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0.5rem 0;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Quick Actions */
.quick-actions {
    background: var(--surface);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.quick-actions h3 {
    margin-bottom: 1.5rem;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    border-radius: 0.75rem;
    text-decoration: none;
    transition: all 0.2s;
    border: 2px solid;
}

.action-btn.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.action-btn.secondary {
    background: var(--surface);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.action-btn.tertiary {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

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

.btn-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.btn-text {
    font-weight: 600;
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.btn-count {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* Progress Section */
.progress-section,
.goals-section,
.activity-section,
.today-summary {
    background: var(--surface);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.progress-section h3,
.goals-section h3,
.activity-section h3,
.today-summary h3 {
    margin-bottom: 1.5rem;
}

/* Goals List Styling */
.goals-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.goal-item {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 1.25rem;
    background: var(--background);
    border-radius: 0.75rem;
    border-left: 4px solid var(--primary);
    transition: all 0.2s ease;
}

.goal-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
    border-left-color: var(--accent);
}

.goal-date {
    flex-shrink: 0;
    width: 60px;
    padding: 0.625rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border-radius: 0.625rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(91, 155, 213, 0.3);
}

.goal-description {
    flex: 1;
    color: var(--text);
    line-height: 1.6;
    font-size: 0.938rem;
}

.view-all-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 0;
    transition: all 0.2s ease;
}

.view-all-link:hover {
    color: var(--accent);
    transform: translateX(4px);
}

.week-card {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

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

.week-progress-pct {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.25rem;
}

.progress-bar {
    background: #e2e8f0;
    height: 8px;
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    background: var(--primary-color);
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.week-categories {
    display: grid;
    gap: 0.5rem;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
}

.category-item a {
    color: var(--text-primary);
    text-decoration: none;
}

.category-item a:hover {
    color: var(--primary-color);
}

.category-progress {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Activity Chart */
.activity-chart {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 150px;
    gap: 1rem;
    padding: 1rem 0;
}

.activity-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 130px; /* Define explicit height for percentage calculations */
}

.bar-fill {
    width: 100%;
    background: var(--primary-color);
    border-radius: 0.25rem 0.25rem 0 0;
    min-height: 4px;
    transition: height 0.3s ease;
}

.bar-label {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Flashcard Study */
.flashcard-study {
    max-width: 800px;
    margin: 0 auto;
}

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

.study-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cards-remaining {
    font-weight: 600;
    color: var(--text-secondary);
}

.flashcard-container {
    perspective: 1000px;
    margin-bottom: 2rem;
}

.flashcard {
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    min-height: 400px;
    max-height: 500px;
    height: 500px;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    position: relative;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    padding-bottom: 4rem;
    text-align: center;
    overflow: hidden;
}

.card-back {
    transform: rotateY(180deg);
}

.card-content {
    font-size: 1.25rem;
    line-height: 1.8;
    max-height: 100%;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom scrollbar for card content */
.card-content::-webkit-scrollbar {
    width: 6px;
}

.card-content::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.card-content::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 3px;
}

.card-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}

.card-reference {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.card-hint {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.rating-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

.rating-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.rating-btn.again {
    background: var(--danger-color);
    color: white;
}

.rating-btn.hard {
    background: var(--warning-color);
    color: white;
}

.rating-btn.good {
    background: var(--success-color);
    color: white;
}

.rating-btn.easy {
    background: var(--primary-color);
    color: white;
}

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

/* Quiz */
.quiz-container {
    max-width: 900px;
    margin: 0 auto;
}

.quiz-setup,
.quiz-active,
.quiz-results {
    background: var(--surface);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
}

.quiz-form {
    max-width: 500px;
    margin: 0 auto;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.quiz-timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.quiz-question {
    background: var(--background);
    padding: 2rem;
    border-radius: 0.75rem;
    margin-bottom: 2rem;
}

.question-number {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.question-text {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.question-reference {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.question-options {
    display: grid;
    gap: 0.75rem;
}

.option-label {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.option-label:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.option-label input[type="radio"] {
    margin-right: 1rem;
}

.option-text {
    flex: 1;
    display: flex;
    align-items: center;
}

.option-letter {
    font-weight: 700;
    margin-right: 0.5rem;
    color: var(--primary-color);
}

/* Quiz Results */
.results-header {
    text-align: center;
    margin-bottom: 3rem;
}

.score-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
}

.score-number {
    font-size: 3rem;
    font-weight: 800;
    color: white;
}

.result-item {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--border-color);
}

.result-item.correct {
    border-left-color: var(--success-color);
}

.result-item.incorrect {
    border-left-color: var(--danger-color);
}

.correct-answer {
    background: #d1fae5 !important;
    border-color: var(--success-color) !important;
}

.wrong-answer {
    background: #fee2e2 !important;
    border-color: var(--danger-color) !important;
}

.answer-indicator {
    margin-left: auto;
    font-weight: 600;
    font-size: 0.875rem;
}

.result-explanation,
.result-reference {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Footer */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 4rem;
}

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

.footer-version {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .main-nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
    
    .study-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Dark Mode Toggle */
.theme-toggle {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
}

.theme-toggle:hover {
    background: var(--background);
    transform: rotate(180deg);
}

/* Scroll to Top Button */
.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
    z-index: 999;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    background: var(--primary-dark);
    transform: translateY(-5px);
    box-shadow: 0 15px 30px -5px rgb(0 0 0 / 0.3);
}

.scroll-to-top:active {
    transform: translateY(-2px);
}

/* Dark mode specific adjustments */
[data-theme="dark"] .countdown-card {
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
}

[data-theme="dark"] .option-label:hover {
    background: #334155;
}

[data-theme="dark"] .dropdown-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}
