/* ==================== Root Variables & Globals ==================== */
:root {
    --primary: #4F46E5;
    --primary-hover: #4338ca;
    --secondary: #8B5CF6;
    --bg-body: #F3F4F6;
    --bg-card: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --success: #10B981;
    --warning: #F59E0B;
    --border: #E5E7EB;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
}

/* ==================== Text Utilities ==================== */
.text-sm {
    font-size: 0.875rem;
}

.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--primary);
}

.font-bold {
    font-weight: 700;
}

.hidden {
    display: none !important;
}

/* ==================== Login Page ==================== */
.login-view {
    height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: hidden;
}

.login-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.login-logo {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

/* ==================== App Layout ==================== */
.app-view {
    display: grid;
    grid-template-columns: 250px 1fr;
    height: 100vh;
}

aside {
    background-color: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.app-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    border-radius: 8px;
    text-decoration: none;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    background-color: #EEF2FF;
    color: var(--primary);
}

.user-profile {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

main {
    padding: 2rem;
    overflow-y: auto;
    position: relative;
}

/* ==================== Forms & Input Fields ==================== */
.input-group {
    margin-bottom: 1rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.input-field, select, textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
}

.input-field:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ==================== Buttons ==================== */
.btn-primary {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--text-muted);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 0.5rem;
}

.btn-secondary:hover {
    background-color: var(--text-main);
}

.btn-add-class {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.btn-add-class:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* ==================== Sections & Headers ==================== */
.section-header {
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
}

.class-header {
    background: linear-gradient(to right, #4F46E5, #8B5CF6);
    color: white;
    padding: 2rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
}

.class-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.class-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.class-header p {
    font-size: 1rem;
    opacity: 0.9;
}

/* ==================== Dashboard Stats ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-info h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-info p {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* ==================== Course/Class Grid ==================== */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.course-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
    text-decoration: none;
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.course-header {
    height: 100px;
    background: linear-gradient(to right, #4F46E5, #8B5CF6);
    padding: 1.5rem;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.course-body {
    padding: 1.5rem;
}

.qr-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.course-card:hover .qr-overlay, .course-card.show-qr .qr-overlay {
    opacity: 1;
}

.qr-placeholder {
    width: 120px;
    height: 120px;
    background-image: radial-gradient(#333 40%, transparent 41%);
    background-size: 10px 10px;
    border: 4px solid white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* ==================== Responses/Diaries ==================== */
.responses-panel, .diary-list {
    background: #FAFAFA;
    border-radius: var(--radius);
    padding: 1rem;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.response-item, .diary-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    animation: slideIn 0.3s ease-out;
}

.diary-item {
    border-left: 4px solid var(--primary);
    padding: 1.5rem;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.resp-header, .diary-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.diary-header {
    margin-bottom: 1rem;
}

.diary-header .student-name {
    font-weight: 700;
    color: var(--text-main);
}

.diary-content {
    margin-top: 1rem;
}

.diary-content p {
    margin-bottom: 0.75rem;
    color: var(--text-main);
}

.diary-content strong {
    color: var(--primary);
}

.diary-rating {
    margin-top: 0.75rem;
    color: var(--warning);
}

/* ==================== Feedback Form (Diary Entry) ==================== */
.feedback-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    height: calc(100vh - 140px);
}

.form-panel {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.star-group {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 5px;
}

.star-group input {
    display: none;
}

.star-group label {
    font-size: 2rem;
    color: #D1D5DB;
    cursor: pointer;
}

.star-group input:checked ~ label,
.star-group label:hover,
.star-group label:hover ~ label {
    color: var(--warning);
}

/* ==================== Charts ==================== */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.chart-card h3 {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 200px;
    margin-top: 1rem;
    border-bottom: 1px solid var(--border);
}

.bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 15%;
}

.bar {
    width: 100%;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    transition: height 1s ease;
    opacity: 0.8;
}

.bar:hover {
    opacity: 1;
}

.bar-label {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pie-chart-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    height: 200px;
}

.pie-chart {
    width: 150px;
    height: 150px;
    border-radius: 50%;
}

/* ==================== Modal ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 500px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.close-btn:hover {
    color: var(--text-main);
}

/* ==================== Alerts ==================== */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.alert-success {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-error {
    background-color: #FEE2E2;
    color: #7F1D1D;
    border: 1px solid #FECACA;
}

.alert i {
    margin-top: 0.25rem;
    flex-shrink: 0;
}

.error {
    color: #DC2626;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ==================== Class Details Page ==================== */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-btn {
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.back-btn:hover {
    color: var(--primary-hover);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.qr-section, .link-section, .diaries-section {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.qr-section h2, .link-section h2, .diaries-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.diaries-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.qr-code-display {
    text-align: center;
    padding: 2rem;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.qr-code-display img {
    max-width: 100%;
    height: auto;
    border: 4px solid white;
    box-shadow: var(--shadow);
}

.link-input-group {
    display: flex;
    gap: 0.5rem;
}

.link-input-group input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
}

.link-input-group button {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.link-input-group button:hover {
    background-color: var(--primary-hover);
}

/* ==================== Empty State ==================== */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ==================== Student Submit Page ==================== */
body.student-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.student-container {
    width: 100%;
    max-width: 600px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.student-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.student-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.student-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.class-info {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    text-align: center;
}

.class-info h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.class-info p {
    opacity: 0.9;
}

.success-message {
    text-align: center;
}

.success-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.success-message h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.success-message p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.reset-btn {
    background-color: var(--text-muted);
    margin-top: 1rem;
}

.reset-btn:hover {
    background-color: var(--text-main);
}

.required {
    color: #DC2626;
}

/* ==================== Responsive Design ==================== */
@media (max-width: 768px) {
    .app-view {
        grid-template-columns: 1fr;
    }

    aside {
        display: none;
    }

    .feedback-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .responses-panel {
        height: 300px;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

    .class-header h1 {
        font-size: 1.5rem;
    }

    .student-container {
        padding: 1.5rem;
    }

    .student-header h1 {
        font-size: 1.25rem;
    }
}

/* ==================== Inline style replacement classes ==================== */
.inline-margin-left-auto {
    margin-left: auto;
}

.inline-font-size-2-5rem {
    font-size: 2.5rem;
}

.text-success {
    color: var(--success);
}

.inline-display-flex-column {
    display: flex;
    flex-direction: column;
}

.inline-margin-bottom-1rem {
    margin-bottom: 1rem;
}

.inline-margin-bottom-0-5rem {
    margin-bottom: 0.5rem;
}

.inline-color-warning {
    color: var(--warning);
}

.inline-background-stat-icon-1 {
    background: #EEF2FF;
    color: var(--primary);
}

.inline-background-stat-icon-2 {
    background: #ECFDF5;
    color: var(--success);
}

.inline-background-stat-icon-3 {
    background: #FFFBEB;
    color: var(--warning);
}

.inline-height-200px {
    height: 200px;
}

.inline-margin-top-0-5rem {
    margin-top: 0.5rem;
}

.inline-margin-top-1rem {
    margin-top: 1rem;
}

.inline-display-inline-block {
    display: inline-block;
}

.inline-text-decoration-none {
    text-decoration: none;
}

.inline-cursor-pointer {
    cursor: pointer;
}

.inline-background-gradient {
    background: linear-gradient(to right, #4F46E5, #8B5CF6);
}

.inline-margin-top-10px {
    margin-top: 10px;
}

.inline-font-size-0-75rem {
    font-size: 0.75rem;
}

.inline-color-text-muted {
    color: var(--text-muted);
}

.inline-margin-top-0-5rem {
    margin-top: 0.5rem;
}

.inline-margin-bottom-0-5rem {
    margin-bottom: 0.5rem;
}

.inline-margin-bottom-2rem {
    margin-bottom: 2rem;
}
