/* =========================================================
   Schulportal - Global Styles
   Professional Design System (BEM)
   ========================================================= */

:root {
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: #eef2ff;
    --color-danger: #ef4444;
    --color-danger-hover: #dc2626;
    --color-success: #22c55e;
    --color-success-hover: #16a34a;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;

    --color-text: #1f2937;
    --color-text-secondary: #374151;
    --color-text-muted: #6b7280;
    --color-text-light: #9ca3af;

    --color-bg: #f3f4f6;
    --color-bg-white: #ffffff;
    --color-border: #e5e7eb;
    --color-border-dark: #d1d5db;

    --radius-sm: 0.25rem;
    --radius: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, ul, ol { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); }
img { max-width: 100%; }

/* Typography */
h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.25; color: var(--color-text); }
h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; color: var(--color-text); }
h3 { font-size: 1.0625rem; font-weight: 600; line-height: 1.4; color: var(--color-text); }
h4 { font-size: 0.9375rem; font-weight: 600; line-height: 1.4; color: var(--color-text-secondary); }

/* =========================================================
   Forms
   ========================================================= */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.form-input::placeholder { color: var(--color-text-light); }
.form-textarea { min-height: 5rem; resize: vertical; }
.form-hint { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.25rem; }
.form-error { font-size: 0.75rem; color: var(--color-danger); margin-top: 0.25rem; }
.form-input--error { border-color: var(--color-danger); }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-hover); }

.btn--secondary { background: var(--color-bg-white); color: var(--color-text-secondary); border-color: var(--color-border); }
.btn--secondary:hover { background: var(--color-bg); }

.btn--danger { background: var(--color-danger); color: #fff; }
.btn--danger:hover { background: var(--color-danger-hover); }

.btn--success { background: var(--color-success); color: #fff; }
.btn--success:hover { background: var(--color-success-hover); }

.btn--sm { padding: 0.3125rem 0.625rem; font-size: 0.8125rem; }
.btn--icon { padding: 0.375rem; border-radius: var(--radius); }

/* =========================================================
   Tables
   ========================================================= */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.875rem;
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfc; }

/* =========================================================
   Cards
   ========================================================= */
.card {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}
.card__title { font-size: 1rem; font-weight: 600; color: var(--color-text); }
.card__body { padding: 1.25rem; }

/* =========================================================
   Badges
   ========================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    line-height: 1.5;
}
.badge--primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge--danger { background: #fef2f2; color: #991b1b; }
.badge--success { background: #f0fdf4; color: #166534; }
.badge--warning { background: #fffbeb; color: #92400e; }
.badge--info { background: #eff6ff; color: #1e40af; }

/* =========================================================
   Modals
   ========================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}
.modal {
    background: var(--color-bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 32rem;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}
.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}
.modal__header h3 { font-size: 1.0625rem; font-weight: 600; }
.modal__body { padding: 1.5rem; }
.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================
   Page Header
   ========================================================= */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-header h1 { font-size: 1.375rem; }

/* =========================================================
   Empty & Loading States
   ========================================================= */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-text-muted);
}
.empty-state__icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state__title { font-size: 1rem; font-weight: 600; color: var(--color-text-secondary); margin-bottom: 0.25rem; }
.empty-state__text { font-size: 0.875rem; }

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 0;
    gap: 0.75rem;
    color: var(--color-text-muted);
}
.loading__spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   Login Page
   ========================================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    padding: 1rem;
}
.login-card {
    background: var(--color-bg-white);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 24rem;
    padding: 2.5rem 2rem;
}
.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.login-logo__icon {
    width: 56px;
    height: 56px;
    background: var(--color-primary);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
    margin-bottom: 0.75rem;
}
.login-logo__title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--color-text);
}
.login-logo__subtitle {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}
.login-error {
    background: #fef2f2;
    color: #991b1b;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
    border: 1px solid #fecaca;
}

/* =========================================================
   Not Found
   ========================================================= */
.not-found {
    text-align: center;
    padding: 4rem 1.5rem;
}
.not-found h1 { font-size: 4rem; font-weight: 800; color: var(--color-text-light); }
.not-found p { color: var(--color-text-muted); margin: 0.5rem 0 1.5rem; }

/* =========================================================
   Utilities
   ========================================================= */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mr-2 { margin-right: 0.5rem; }
.ml-2 { margin-left: 0.5rem; }
