/* DojoTrack — Karate School Management */

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-dark: #1a1a2e;
    --bg-sidebar: #16213e;
    --bg-main: #f5f5f7;
    --bg-white: #ffffff;
    --accent: #c0392b;
    --accent-hover: #a93226;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-light: #bdc3c7;
    --text-white: #ecf0f1;
    --border: #e0e0e0;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Layout === */
.app {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: 250px;
    background: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.sidebar-logo-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-white);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-white);
    font-size: 1.5rem;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-light);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    font-size: 0.95rem;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-white);
    text-decoration: none;
}

.nav-item.active {
    background: rgba(192, 57, 43, 0.3);
    color: var(--text-white);
    border-left: 3px solid var(--accent);
}

.nav-icon { font-size: 1.1rem; width: 1.2rem; text-align: center; }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.user-name { color: var(--text-light); }
.logout-link { color: var(--text-light); }
.logout-link:hover { color: var(--text-white); }

/* === Main Content === */
.main-content {
    flex: 1;
    margin-left: 250px;
    min-height: 100vh;
}

.top-bar {
    background: var(--bg-white);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-primary);
}

.page-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.content {
    padding: 1.5rem;
    max-width: 1200px;
    overflow-x: hidden;
}

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

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

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

.card-header-row h3 { margin-bottom: 0; }

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

.stats-grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card-warning { border-left: 3px solid var(--warning); }

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    line-height: 1.4;
}

.btn:hover { background: var(--bg-main); text-decoration: none; }

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover { background: #fdf0f0; }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

.btn-full { display: block; width: 100%; text-align: center; }

.btn-attendance {
    display: block;
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    padding: 1rem;
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th, .table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover { background: #f8f9fa; }

.table-compact td, .table-compact th { padding: 0.4rem 0.5rem; }

.row-inactive { opacity: 0.5; }

.student-link { font-weight: 500; }

/* === Badges === */
.belt-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #333;
    border: 1px solid rgba(0,0,0,0.15);
}

.belt-badge-sm { padding: 0.1rem 0.5rem; font-size: 0.75rem; }

/* White belt needs dark text, dark belts need light text */
.belt-badge[style*="background:#000"], .belt-badge[style*="background:#8B4513"],
.belt-badge[style*="background:#1E90FF"], .belt-badge[style*="background:#228B22"] {
    color: white;
    border-color: transparent;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-paid { background: #e8f5e9; color: var(--success); }
.badge-unpaid { background: #fde8e8; color: var(--danger); }
.badge-inactive { background: #f0f0f0; color: var(--text-secondary); }

/* === Forms === */
.form-card { max-width: 700px; }

/* === Belt Config Cards === */
.belt-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.belt-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    background: #fafafa;
}

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

.belt-card-order {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.form-group {
    margin-bottom: 1rem;
    flex: 1;
}

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

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-white);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.15);
}

.form-group input[type="color"] {
    height: 38px;
    padding: 2px;
    cursor: pointer;
}

.input-sm { max-width: 200px; }

.form-row {
    display: flex;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input { width: auto; }

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

.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.alert-error { background: #fde8e8; color: #c62828; border: 1px solid #ffcdd2; }

/* === Toolbar & Search === */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    width: 200px;
}

.search-select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.filter-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-row select {
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

/* === Date Selector === */
.date-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.date-selector input[type="date"] {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
}

/* === Attendance List === */
.attendance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.attendance-list {
    display: flex;
    flex-direction: column;
}

.attendance-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.1s;
}

.attendance-item:hover { background: #f8f9fa; }

.attendance-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.student-name { flex: 1; font-weight: 500; }

/* === Student Detail === */
.student-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.student-header h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

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

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* === Progress Bar === */
.progress-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 6px;
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* === Info List === */
.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1rem;
    font-size: 0.9rem;
}

.info-list dt { color: var(--text-secondary); font-weight: 500; }
.info-list dd { color: var(--text-primary); }

/* === Belt Timeline === */
.belt-timeline {
    list-style: none;
    padding: 0;
}

.belt-timeline li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

/* === Date List === */
.date-list {
    list-style: none;
    padding: 0;
    columns: 2;
    font-size: 0.9rem;
}

.date-list li {
    padding: 0.3rem 0;
    border-bottom: 1px solid #f8f8f8;
}

/* === Activity List === */
.activity-list {
    list-style: none;
    padding: 0;
}

.activity-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

/* === Login === */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-dark);
}

.login-container { text-align: center; }

.login-card {
    background: var(--bg-white);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    width: 360px;
    max-width: 90vw;
}

.login-logo-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 1rem;
}

.login-logo {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.login-footer {
    color: var(--text-light);
    font-size: 0.8rem;
    margin-top: 1.5rem;
}

.text-muted { color: var(--text-secondary); }

/* === Mobile Responsive === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close { display: block; }

    .main-content { margin-left: 0; }

    .hamburger { display: block; }

    .content { padding: 1rem; }

    .form-row { flex-direction: column; gap: 0; }

    .detail-grid { grid-template-columns: 1fr; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .toolbar { flex-direction: column; align-items: stretch; }

    .search-form { flex-direction: column; }

    .search-input { width: 100%; }

    .student-header { flex-direction: column; }

    .date-list { columns: 1; }

    .filter-row { flex-direction: column; }

    .table { font-size: 0.8rem; }
    .table th, .table td { padding: 0.4rem; }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}

.sidebar-overlay.active { display: block; }
