:root {
    --primary-color: #6a11cb;
    --secondary-color: #2575fc;
    --primary-gradient: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    --accent-color: #00ffc3;
    --background-color: #f0f2f5;
    --surface-color: #ffffff;
    --text-color: #3d405b;
    --text-color-light: #f8f9fa;
    --border-color: #e0e0e0;
    --shadow-color: rgba(90, 116, 148, 0.2);
    --error-color: #e74c3c;
    --font-family: 'Poppins', sans-serif;
}

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

html, body, #root {
    height: 100%;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    overflow: hidden; /* Prevent body scroll */
}

#root {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 1rem;
}

/* Login/Register Screen */
.login-screen-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-gradient);
    z-index: -1;
}

.login-container {
    max-width: 450px;
    width: 100%;
    background-color: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    padding: 2.5rem;
    transition: all 0.3s ease-in-out;
}

.login-container h1 {
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-color);
}

.logo-line-1 {
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 1rem;
}

.logo-line-2 {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.logo-r-circle {
    font-size: 2.4rem;
    font-weight: 700;
    border: 5px solid var(--text-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
}

.logo-name-container {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.logo-name-sedat,
.logo-name-yayla {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.2;
}

.auth-toggle {
    display: flex;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    background-color: #f0f2f5;
    padding: 0.25rem;
}

.auth-toggle-btn {
    flex: 1;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    background-color: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--secondary-color);
    border-radius: 6px;
}

.auth-toggle-btn.active {
    background: var(--surface-color);
    color: var(--primary-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

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

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

.form-group input, .form-group select {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(37, 117, 252, 0.2);
}


/* Dashboard Screen */
.dashboard-layout {
    display: flex;
    width: 100%;
    height: 100%;
    max-width: 1400px; /* Max width for large screens */
    max-height: 95vh; /* Max height to fit nicely */
    background-color: var(--surface-color);
    border-radius: 16px;
    box-shadow: 0 8px 40px var(--shadow-color);
    overflow: hidden;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--primary-gradient);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    color: var(--text-color-light);
}

.sidebar-header {
    margin-bottom: 2.5rem;
    padding: 0 0.5rem;
}
.sidebar-header h2 {
    font-size: 1.6rem;
    text-align: left;
    color: var(--text-color-light);
    font-weight: 700;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
}

.sidebar-menu li {
    margin-bottom: 0.5rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: left;
    border: none;
    background-color: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: var(--text-color-light);
}

.menu-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.menu-item.active {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

.logout-btn-sidebar {
    width: 100%;
    margin-top: auto;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}
.logout-btn-sidebar:hover {
    background: rgba(255, 255, 255, 0.2);
}

.dashboard-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
}

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

.dashboard-header h1 {
    margin-bottom: 0;
    font-size: 1.8rem;
    font-weight: 600;
}

#dashboard-main, #student-main-content {
    padding: 2rem;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Common Components */
.card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px var(--shadow-color);
    transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--shadow-color);
}

.card h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.2rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-footer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: right;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary-gradient);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.btn svg {
    width: 1.1em;
    height: 1.1em;
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.btn-secondary {
    background: #6c757d;
}
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}
.btn-danger {
    background: var(--error-color);
}

/* Page Headers & Navigation */
.page-navigation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}
.page-navigation-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}
.page-navigation-actions {
    display: flex;
    gap: 0.75rem;
}
.page-navigation-actions .btn {
    width: auto;
}

/* Specific Component Styles */
textarea {
    width: 100%;
    min-height: 150px;
    padding: 0.75rem;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}
textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(37, 117, 252, 0.2);
}

.file-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    background-color: #f8f9fa;
}

#analysis-result, .analysis-result-box {
    padding: 1.5rem;
    background-color: #f8faff;
    border-left: 5px solid var(--secondary-color);
    border-radius: 4px;
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.7;
    margin-top: 1.5rem;
}

.history-list { list-style: none; }
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-radius: 8px;
    transition: background-color 0.2s;
}
.history-item:hover { background-color: #f8f9fa; }
.history-item + .history-item { margin-top: 0.5rem; }
.history-item-info span { font-size: 0.9rem; color: #6c757d; }
.history-item-actions { display: flex; gap: 0.5rem; }

.student-list-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem; border-radius: 8px; transition: background-color 0.2s;
}
.student-list-item:hover { background-color: #f8f9fa; }

.student-profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.profile-card-full {
    grid-column: 1 / -1;
}

.average-score {
    font-size: 3.5rem; font-weight: 700; text-align: center;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.score-list { list-style: none; }
.score-list li {
    display: flex; justify-content: space-between; padding: 0.75rem 0.25rem;
    border-bottom: 1px solid #f0f0f0;
}
.score-list li:last-child { border-bottom: none; }

.score-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.25rem;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}
.score-list-item:last-child { border-bottom: none; }

.subject-name-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font-weight: bold;
    font-size: inherit;
    font-family: inherit;
    color: var(--text-color);
    cursor: pointer;
    transition: color 0.2s;
    white-space: normal;
    text-align: left;
    margin-right: 0.5rem;
}
.subject-name-btn:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.score-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.score-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.score-indicator.up {
    background-color: #2ecc71;
}

.score-indicator.down {
    background-color: var(--error-color);
}

.chart-container { position: relative; height: 300px; width: 100%; }

/* Subject History Chart View */
.subject-history-view {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-grow: 1;
    width: 100%;
}

.card.chart-card-enhanced {
    width: 100%;
    max-width: 900px;
    flex-shrink: 0;
    margin-bottom: 0;
}


.loader-container {
    display: flex; justify-content: center; align-items: center;
    padding: 2rem; width: 100%; min-height: 200px;
}
.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.error-message {
    color: var(--error-color);
    font-weight: 500;
    background-color: #fdedec;
    border: 1px solid var(--error-color);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

/* DB Error Box */
.db-error-box {
    background-color: #fffbe6; border: 1px solid #ffe58f;
    border-left: 5px solid #faad14; padding: 1.5rem; border-radius: 8px;
}
.db-error-box h4 { color: #d46b08; }
pre.code-block {
    background-color: #f5f5f5; border: 1px solid #ddd;
    padding: 1rem; border-radius: 4px; overflow-x: auto;
}

.data-table-container {
    margin-top: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: auto;
}

.data-table-container table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table-container th,
.data-table-container td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border-color);
    white-space: normal;
    font-size: 0.9rem;
}

.data-table-container .grades-cell {
    white-space: normal;
    word-break: break-word;
}

.data-table-container th {
    background-color: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table-container tbody tr:last-child td {
    border-bottom: none;
}

.data-table-container tbody tr:hover {
    background-color: #f0f2f5;
}

.score-above-avg {
    color: #2ecc71;
}
.score-below-avg {
    color: var(--error-color);
}

/* Performance Overview Card */
.performance-overview-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.performance-overview-card h3 {
    width: 100%;
    text-align: center;
}

.average-score-display {
    margin: 1rem 0;
    line-height: 1;
}

.average-score-display .average-score {
    font-size: 4rem;
    line-height: 1;
}

.average-score-display span {
    font-size: 1rem;
    color: #6c757d;
    font-weight: 500;
}

.rank-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background-color: #f8faff;
    border-radius: 50px;
    border: 1px solid #e0e7ff;
}

.rank-display .trophy-icon {
    width: 28px;
    height: 28px;
    color: #f59e0b; /* Amber color */
}

.rank-text {
    font-size: 1rem;
    color: var(--text-color);
    margin: 0;
}

.rank-value {
    display: block;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-color);
}

/* Responsive */
@media (max-width: 992px) {
    .dashboard-layout {
        flex-direction: column;
        max-height: none;
        height: 100%;
        border-radius: 0;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 0.5rem 1rem;
        flex-direction: row;
        align-items: center;
    }
    .sidebar-header { display: none; }
    .sidebar-menu { display: flex; flex-grow: 1; gap: 0.5rem; overflow-x: auto; }
    .sidebar-menu li { margin-bottom: 0; flex-shrink: 0; }
    .menu-item { flex-direction: column; gap: 0.2rem; padding: 0.5rem; font-size: 0.8rem;}
    .menu-item svg { margin-bottom: 0.2rem; }
    .logout-btn-sidebar { margin-top: 0; margin-left: auto; width: auto; }
    .dashboard-content { padding: 1rem; }
    #dashboard-main, #student-main-content { padding: 1rem; }
    .dashboard-header { padding: 1rem; }
    .dashboard-header h1 { font-size: 1.5rem; }
}

@media (max-width: 600px) {
    #root { padding: 0; }
    .login-container {
        padding: 2rem;
        border-radius: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .dashboard-header { flex-direction: column; gap: 0.5rem; }
    .page-navigation-header { flex-direction: column; gap: 1rem; }
    .page-navigation-actions { width: 100%; }
    .page-navigation-actions .btn { flex-grow: 1; text-align: center; }
}