@import 'variables.css';

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text-main);
    line-height: 1.6;
    overflow-x: hidden;
    background-image: var(--gradient-glow);
    background-attachment: fixed;
    min-height: 100vh;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-5px);
    }

    100% {
        transform: translateY(0px);
    }
}

@keyframes pulse-soft {
    0% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.2);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(79, 70, 229, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.animate-slide-in {
    animation: slideIn 0.3s ease-out forwards;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--color-text-main);
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: all 0.2s;
}

button {
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

/* Glass Card Utility */
.glass-card {
    background: var(--color-surface-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-xl);
    border-radius: var(--radius-xl);
    transition: transform 0.2s, box-shadow 0.2s;
}

.page-transition {
    animation: pageFadeIn 0.3s ease-out;
}

@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.glass-panel {
    /* PERFORMANCE: Removed nested backdrop-filter to prevent GPU overload */
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: var(--radius-lg);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-colored);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px -10px rgba(79, 70, 229, 0.5);
}

.btn-secondary {
    background: white;
    color: var(--color-text-main);
    border: 1px solid #E2E8F0;
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: #F8FAFC;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 50%;
}

/* Form Elements */
.input-group {
    margin-bottom: 1.5rem;
}

.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-main);
    margin-bottom: 0.5rem;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid #E2E8F0;
    background: #F8FAFC;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
    background: white;
}

/* Grid Layouts */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Navbar */
.navbar {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Main Layout */
.app-container {
    padding-top: calc(var(--header-height) + 2rem);
    padding-bottom: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
    min-height: 100vh;
}

@media (max-width: 768px) {
    .app-container {
        padding-top: calc(var(--header-height) + 1rem);
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

.hidden {
    display: none !important;
}

/* Status Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-success {
    background: #DCFCE7;
    color: #166534;
}

.badge-warning {
    background: #FEF3C7;
    color: #92400E;
}

.badge-info {
    background: #E0F2FE;
    color: #075985;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Responsive Dashboard Layout */
.dashboard-split {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .dashboard-split {
        grid-template-columns: 1fr;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease-out;
    height: 100vh;
    width: 100vw;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    margin: 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
}

.modal-close:hover {
    color: var(--color-text-main);
}

/* Teacher-added text styling - bold for additions */
.teacher-addition {
    font-weight: 700;
    color: var(--color-primary-dark);
}

/* Comprehensive Responsive Design */

/* Tablets and landscape phones (max-width: 1024px) */
@media (max-width: 1024px) {
    .navbar {
        padding: 0 1rem;
    }

    .logo {
        font-size: 1.25rem;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    /* Make 2-column forms single column on tablets */
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Dashboard adjustments */
    header[style*="display: flex"] {
        flex-direction: column;
        align-items: flex-start !important;
    }
}

/* Mobile devices (max-width: 768px) */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .navbar {
        height: 60px;
        padding: 0 0.75rem;
    }

    .logo {
        font-size: 1.1rem;
    }

    .app-container {
        padding-top: calc(60px + 1rem);
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    h3 {
        font-size: 1.1rem !important;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.875rem;
    }

    /* Form elements */
    .input,
    .select,
    .textarea {
        font-size: 14px;
    }

    /* Tables responsive */
    table {
        font-size: 0.85rem;
    }

    table th,
    table td {
        padding: 0.5rem !important;
    }

    /* Glass cards */
    .glass-card {
        padding: 1rem !important;
    }

    /* Modal improvements */
    .modal-content {
        width: 95%;
        padding: 1.5rem;
        max-height: 85vh;
    }

    /* Grid adjustments */
    .grid {
        gap: 1rem;
    }

    /* Flex layouts */
    div[style*="display: flex"] {
        flex-wrap: wrap;
    }

    /* Subject selection checkboxes */
    label.glass-panel {
        padding: 0.75rem !important;
    }

    /* Rating buttons */
    .rating-btn {
        width: 35px !important;
        height: 35px !important;
        font-size: 0.875rem !important;
    }

    /* Stats cards */
    div[style*="border-left: 5px"] {
        padding: 1rem !important;
    }

    div[style*="border-left: 5px"] > div:first-child {
        font-size: 0.75rem !important;
    }

    div[style*="border-left: 5px"] > div:nth-child(2) {
        font-size: 1.5rem !important;
    }

    /* Tabs */
    #admin-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    #admin-tabs button {
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }
}

/* Small mobile devices (max-width: 480px) */
@media (max-width: 480px) {
    .navbar {
        height: 55px;
    }

    .logo {
        font-size: 1rem;
    }

    .logo span {
        display: none;
    }

    h1 {
        font-size: 1.25rem !important;
    }

    .btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.8rem;
    }

    .btn-icon {
        padding: 0.4rem;
    }

    .glass-card {
        padding: 0.875rem !important;
    }

    .modal-content {
        padding: 1rem;
    }

    .input,
    .select,
    .textarea {
        padding: 0.6rem 0.875rem;
        font-size: 14px;
    }

    /* Stack buttons vertically on very small screens */
    div[style*="justify-content: flex-end"] button,
    div[style*="justify-content: space-between"] button {
        width: 100%;
        margin: 0.25rem 0 !important;
    }

    /* Table horizontal scroll */
    .glass-panel {
        overflow-x: auto;
    }

    table {
        min-width: 500px;
    }
}

/* Landscape phone optimization */
@media (max-width: 900px) and (orientation: landscape) {
    .app-container {
        padding-top: calc(var(--header-height) + 0.5rem);
    }

    .modal-content {
        max-height: 80vh;
    }
}

/* Print styles */
@media print {
    .navbar,
    .btn,
    button {
        display: none !important;
    }

    .app-container {
        padding: 0;
    }

    .glass-card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
}

/* RTL Support for Arabic */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .logo {
    flex-direction: row-reverse;
}

[dir="rtl"] .btn {
    flex-direction: row-reverse;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .glass-card,
    .glass-panel {
        border-width: 2px;
    }

    .btn {
        border-width: 2px;
    }
}
