/* CSS Variables and Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Playful color palette inspired by PDF */
    --primary-purple: #8B5FBF;
    --bright-orange: #FF9B47;
    --sunny-yellow: #FFD93D;
    --grass-green: #6BCF7F;
    --sky-blue: #4ECDC4;
    --coral-pink: #FF6B9D;
    --soft-lavender: #C8A8E9;
    
    /* Additional variables for consistency */
    --primary: var(--primary-purple);
    --primary-rgb: 139, 95, 191;
    --secondary: var(--bright-orange);
    --success-green: #10B981;
    --error-red: #EF4444;
    
    /* Functional colors */
    --text-dark: #2D3748;
    --text-medium: #4A5568;
    --text-light: #718096;
    --bg-light: #F7FAFC;
    --white: #FFFFFF;
    --shadow: rgba(0,0,0,0.1);
    --shadow-hover: rgba(0,0,0,0.15);
}

/* Base Styles */
body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--soft-lavender) 0%, var(--sky-blue) 50%, var(--sunny-yellow) 100%);
    min-height: 100vh;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Prevent printing */
@media print {
    body { display: none !important; }
}

/* Layout Components */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Loading States */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

.loading-spinner.large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

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

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

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

/* Performance optimizations */
* {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Optimize repaints */
.user-card,
.btn,
.modal {
    will-change: transform, opacity;
}

/* Critical CSS above the fold - rest will be in components.css */

/* ============================================
   CONTENT PROTECTION MODAL
   ============================================ */

.content-protection-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.content-protection-modal .modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.content-protection-modal .modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    animation: modalAppear 0.3s ease-out;
}

.content-protection-modal .modal-header {
    background: linear-gradient(135deg, var(--primary-purple), var(--bright-orange));
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.content-protection-modal .modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.content-protection-modal .modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.content-protection-modal .modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.content-protection-modal .modal-body {
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
}

.protected-content-notice {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border: 1px solid #f87171;
    color: #dc2626;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 500;
    text-align: center;
}

.protected-content-display {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

.protected-content-display h1,
.protected-content-display h2,
.protected-content-display h3 {
    color: var(--primary-purple);
    margin-bottom: 1rem;
}

.protected-content-display p {
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.protected-content-display ul {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.protected-content-display li {
    margin-bottom: 0.5rem;
    color: var(--text-medium);
}

/* Content protection styles */
.protected-content {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    pointer-events: auto;
}

.protected-content * {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* Disable image drag */
.protected-content img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

/* Protection indicator */
.protected-content::before {
    content: '🔒';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(139, 95, 191, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    z-index: 1;
}

.content-card.protected-content {
    position: relative;
    border: 2px solid rgba(139, 95, 191, 0.2);
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Print protection */
@media print {
    .protected-content,
    .protected-content-display {
        display: none !important;
    }
}

/* ============================================
   ADMIN CONTENT MANAGEMENT STYLES
   ============================================ */

.admin-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid #e2e8f0;
}

.tab-button {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-medium);
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-button:hover {
    color: var(--primary);
    background: rgba(139, 95, 191, 0.05);
}

.tab-button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(139, 95, 191, 0.1);
}

.modal-content.large {
    max-width: 800px;
    width: 95%;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 95, 191, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-light);
    font-size: 0.875rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.topic-management-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e2e8f0;
}

.topic-management-section:last-child {
    border-bottom: none;
}

.topic-management-section h4 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.subject-section {
    margin-bottom: 1.5rem;
}

.subject-section h5 {
    margin-bottom: 0.75rem;
    color: var(--text-dark);
    font-weight: 600;
}

.topic-items {
    display: grid;
    gap: 0.5rem;
}

.topic-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.topic-icon {
    font-size: 1.25rem;
    min-width: 1.5rem;
}

.topic-name {
    flex: 1;
    font-weight: 500;
}

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

.lessons-management {
    padding-top: 1rem;
}

.lessons-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
}

.lessons-filters select {
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
}

.lessons-list {
    display: grid;
    gap: 1rem;
}

.lesson-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.5rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: box-shadow 0.2s;
}

.lesson-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.lesson-info h4 {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.lesson-meta {
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.lesson-description {
    color: var(--text-medium);
    margin-bottom: 0.5rem;
}

.lesson-details {
    color: var(--text-light);
    font-size: 0.875rem;
}

.lesson-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.analytics-section {
    padding-top: 1rem;
}

.analytics-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.analytics-card {
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--primary-purple), var(--bright-orange));
    color: white;
    border-radius: 8px;
    text-align: center;
}

.analytics-card h4 {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    opacity: 0.9;
}

.analytics-number {
    font-size: 2rem;
    font-weight: bold;
}

.upload-status-section {
    padding-top: 1rem;
}

.upload-list {
    display: grid;
    gap: 1rem;
}

.loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-light);
    font-style: italic;
}

.text-muted {
    color: var(--text-light);
}

/* ============================================
   CALENDAR SYSTEM STYLES
   ============================================ */

.calendar-weekly-view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    padding: 1rem 0;
}

.week-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s;
}

.week-card.has-content {
    border-left: 4px solid var(--primary-purple);
    box-shadow: 0 2px 8px rgba(139, 95, 191, 0.1);
}

.week-card.empty {
    border-left: 4px solid #e2e8f0;
    opacity: 0.7;
}

.week-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.week-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.week-header h4 {
    margin: 0;
    color: var(--primary-purple);
    font-size: 1.1rem;
}

.lesson-count {
    background: var(--primary-purple);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.week-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.subject-column h5 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-medium);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.lesson-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.lesson-item:hover {
    background: var(--primary-purple);
    color: white;
    border-color: var(--primary-purple);
}

.lesson-title {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.lesson-type {
    display: block;
    font-size: 0.75rem;
    opacity: 0.8;
    text-transform: capitalize;
}

.no-lessons {
    color: var(--text-light);
    font-style: italic;
    font-size: 0.875rem;
    margin: 0;
    text-align: center;
    padding: 1rem 0;
}

/* Calendar Overview Term Cards */
.content-card.enhanced.planning {
    position: relative;
    overflow: hidden;
}

.content-card.enhanced.planning::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-purple), var(--bright-orange));
}

/* Single column layout for narrow screens */
@media (max-width: 640px) {
    .week-content {
        grid-template-columns: 1fr;
    }

    .calendar-weekly-view {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   HOMEWORK SYSTEM STYLES
   ============================================ */

.homework-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.homework-section {
    margin-bottom: 1rem;
}

.homework-section h5 {
    margin: 0 0 0.75rem 0;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
}

.homework-section.overdue h5 {
    background: #fee2e2;
    color: #dc2626;
}

.homework-section.pending h5 {
    background: #fef3c7;
    color: #d97706;
}

.homework-section.completed h5 {
    background: #d1fae5;
    color: #059669;
}

.homework-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.homework-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.homework-item.overdue {
    border-left: 4px solid #dc2626;
    background: #fefefe;
}

.homework-item.pending {
    border-left: 4px solid #d97706;
}

.homework-item.completed {
    border-left: 4px solid #059669;
    opacity: 0.8;
}

.homework-content {
    flex: 1;
}

.homework-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.homework-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.homework-priority {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    text-transform: uppercase;
}

.homework-priority.priority-high {
    background: #fee2e2;
    color: #dc2626;
}

.homework-priority.priority-medium {
    background: #fef3c7;
    color: #d97706;
}

.homework-priority.priority-low {
    background: #e0e7ff;
    color: #4f46e5;
}

.homework-subject {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: var(--primary-purple);
    font-weight: 500;
}

.homework-description {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    color: var(--text-medium);
    line-height: 1.4;
}

.homework-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

.due-date,
.submitted-date {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.homework-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.homework-grade {
    background: var(--success-green);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Homework mobile responsiveness */
@media (max-width: 640px) {
    .homework-item {
        flex-direction: column;
        align-items: stretch;
    }

    .homework-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .homework-actions {
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
    }

    .homework-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .admin-tabs {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .tab-button {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .lesson-item {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .lesson-actions {
        justify-content: flex-start;
    }

    .analytics-cards {
        grid-template-columns: 1fr;
    }
}