/* WebUntis KV-Tool - Styles */

:root {
    --primary: #e67e22;
    --primary-dark: #d35400;
    --primary-light: #fdebd0;
    --success: #27ae60;
    --success-light: #d5f5e3;
    --danger: #e74c3c;
    --danger-light: #fadbd8;
    --warning: #f39c12;
    --warning-light: #fef9e7;
    --gray-50: #f8f9fa;
    --gray-100: #ecf0f1;
    --gray-200: #d5dbdb;
    --gray-300: #bdc3c7;
    --gray-500: #95a5a6;
    --gray-700: #7f8c8d;
    --gray-900: #2c3e50;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
}

/* Header */
.header {
    background: var(--gray-900);
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

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

.header .user-info {
    font-size: 0.85rem;
    color: var(--gray-300);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
    background: transparent;
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.login-method-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 1rem; }

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-card h2 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--gray-900);
}

.login-card .subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.3rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Main Layout */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-100);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.7rem 1.2rem;
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}

.tab:hover { color: var(--gray-900); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

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

.card-header h3 {
    font-size: 1.1rem;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 0.7rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-100);
}

td {
    padding: 0.7rem 0.8rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--gray-100);
}

tr:hover { background: var(--gray-50); }

/* Status Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-excused { background: var(--success-light); color: var(--success); }
.badge-unexcused { background: var(--danger-light); color: var(--danger); }
.badge-pending { background: var(--warning-light); color: var(--warning); }

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

.stat-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.2rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    text-transform: uppercase;
    font-weight: 600;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Alerts */
.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid var(--success); }
.alert-info { background: #d6eaf8; color: #2980b9; border: 1px solid #2980b9; }

/* Toast */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 90%;
    max-width: 500px;
}

.modal h3 { margin-bottom: 1rem; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.empty-state p { margin-top: 0.5rem; }

/* Timetable */
.tt-day { margin-bottom: 1.5rem; }
.tt-day-header {
    font-weight: 600;
    font-size: 1rem;
    padding: 0.5rem 0;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 0.5rem;
    color: var(--gray-900);
}
.tt-cancelled td { opacity: 0.5; text-decoration: line-through; }
.tt-cancelled td:last-child { text-decoration: none; opacity: 1; }

/* Messages */
.messages-list { display: flex; flex-direction: column; gap: 0.75rem; }
.message-item {
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    border-left: 3px solid var(--primary);
}
.message-subject { font-weight: 600; margin-bottom: 0.3rem; }
.message-body { color: var(--gray-700); }
.message-attachments { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.3rem; }

/* Date Presets */
.date-presets {
    display: flex;
    gap: 0;
    margin-top: 0.3rem;
}

.date-presets .date-preset {
    border-radius: 0;
    border-right: none;
}

.date-presets .date-preset:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

.date-presets .date-preset:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
    border-right: 1px solid var(--gray-200);
}

.date-presets .date-preset.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Admin */
.admin-export-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.admin-result-area {
    margin-top: 1rem;
    border-top: 1px solid var(--gray-100);
    padding-top: 1rem;
}

.admin-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.admin-result-header span {
    font-size: 0.9rem;
    color: var(--gray-700);
    font-weight: 500;
}

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

.admin-table-container {
    max-height: 500px;
    overflow: auto;
}

.admin-table-container table {
    font-size: 0.85rem;
}

.admin-table-container th {
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

/* Absence bar */
.abs-bar {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--gray-100);
}

.abs-bar-exc {
    background: var(--success);
    height: 100%;
}

.abs-bar-unexc {
    background: var(--danger);
    height: 100%;
}

/* Platform */
.btn-ms {
    background: #2f2f2f;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}
.btn-ms:hover { background: #1a1a1a; }

.student-card {
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.student-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.student-card-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.student-card .class-badge {
    font-size: 0.75rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
}

.parent-email-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.parent-email-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    background: var(--gray-50);
    border-radius: 4px;
    font-size: 0.85rem;
}

.parent-email-item .pe-info {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.parent-email-item .pe-relation {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.setup-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.setup-step-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.setup-step-done .setup-step-icon {
    background: var(--success-light);
    color: var(--success);
}

.setup-step-pending .setup-step-icon {
    background: var(--warning-light);
    color: var(--warning);
}

.setup-step-info {
    flex: 1;
}

.setup-step-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.setup-step-desc {
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* Hidden */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
    .header { padding: 0.5rem 1rem; }
    .header h1 { font-size: 1rem; }
    .main-container { padding: 1rem; }
    .filter-bar { flex-direction: column; }
    .stats { grid-template-columns: 1fr 1fr; }
    .tabs { overflow-x: auto; }
    .tab { white-space: nowrap; padding: 0.5rem 0.8rem; font-size: 0.85rem; }

    table { font-size: 0.85rem; }
    th, td { padding: 0.5rem; }

    .login-card { padding: 1.5rem; }
}

@media (max-width: 480px) {
    .stats { grid-template-columns: 1fr; }
}
