/* SchoolFlow ERP - base styles (Phase 3 will expand into full theme system) */
* { box-sizing: border-box; }
body { font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif; margin: 0; background: #f4f6f9; color: #1f2937; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #111827; color: #fff; }
.sidebar-brand { padding: 20px; font-weight: 700; font-size: 1.1rem; }
.sidebar nav a { display: block; padding: 10px 20px; color: #cbd5e1; text-decoration: none; }
.sidebar nav a:hover { background: #1f2937; color: #fff; }
.nav-group { padding: 14px 20px 4px; font-size: .75rem; text-transform: uppercase; color: #6b7280; }
.app-main { flex: 1; display: flex; flex-direction: column; }
.app-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: #fff; border-bottom: 1px solid #e5e7eb; }
.app-content { padding: 24px; }
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f4f6f9; }
.auth-card { background: #fff; padding: 32px; border-radius: 10px; width: 340px; box-shadow: 0 4px 20px rgba(0,0,0,.08); }
.auth-card label { display: block; margin-bottom: 14px; font-size: .9rem; }
.auth-card input { width: 100%; padding: 8px; margin-top: 4px; border: 1px solid #d1d5db; border-radius: 6px; }
.auth-card button { width: 100%; padding: 10px; background: #2563eb; color: #fff; border: none; border-radius: 6px; cursor: pointer; }
.alert { padding: 10px; border-radius: 6px; margin-bottom: 14px; font-size: .9rem; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

/* Phase 2: data tables, forms, toolbars */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 8px; }
.toolbar input[type="text"] { padding: 8px; border: 1px solid #d1d5db; border-radius: 6px; }
.btn { background: #2563eb; color: #fff; padding: 8px 14px; border-radius: 6px; text-decoration: none; }
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: .9rem; }
.data-table th { background: #f9fafb; }
.link-danger { background: none; border: none; color: #dc2626; cursor: pointer; padding: 0; font-size: .9rem; }
.pagination { margin-top: 14px; display: flex; gap: 6px; }
.pagination a { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; text-decoration: none; color: #374151; }
.pagination a.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.form-card { background: #fff; padding: 24px; border-radius: 10px; max-width: 520px; }
.form-card label { display: block; margin-bottom: 14px; font-size: .9rem; font-weight: 600; }
.form-card input[type="text"], .form-card input[type="email"], .form-card input[type="password"], .form-card select {
    width: 100%; padding: 8px; margin-top: 4px; border: 1px solid #d1d5db; border-radius: 6px; font-weight: normal;
}
.form-card fieldset { border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; margin-bottom: 16px; }
.form-card legend { font-weight: 700; padding: 0 6px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: normal; margin-bottom: 6px; }
.checkbox-row input { width: auto; }
.permission-group { margin-bottom: 14px; }
.hint { font-weight: normal; color: #6b7280; font-size: .8rem; }
.form-card button { background: #2563eb; color: #fff; border: none; padding: 10px 18px; border-radius: 6px; cursor: pointer; margin-right: 10px; }

/* Phase 3: school setup */
.form-card-wide { max-width: 760px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 16px; }
.inline-form { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.inline-form input, .inline-form select { padding: 8px; border: 1px solid #d1d5db; border-radius: 6px; }
.inline-form button { background: #2563eb; color: #fff; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; }
.inline-input { padding: 6px; border: 1px solid #d1d5db; border-radius: 6px; width: 100%; }
.link-action { background: none; border: none; color: #2563eb; cursor: pointer; padding: 0; font-size: .9rem; margin-right: 10px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; padding: 18px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.stat-card .value { font-size: 1.8rem; font-weight: 700; color: #111827; }
.stat-card .label { color: #6b7280; font-size: .85rem; margin-top: 4px; }

/* Phase 4: parent linking widget on the student form */
.parent-chip { display: flex; align-items: center; justify-content: space-between; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px 12px; margin-bottom: 6px; }
.parent-chip .checkbox-row { margin-bottom: 0; }
.parent-search { position: relative; margin-top: 10px; }
.parent-search input { width: 100%; padding: 8px; border: 1px solid #d1d5db; border-radius: 6px; }
#parent-search-results { position: relative; }
.parent-search-item { padding: 8px 10px; background: #fff; border: 1px solid #e5e7eb; border-top: none; cursor: pointer; font-size: .9rem; }
.parent-search-item:hover { background: #f3f4f6; }
details summary { cursor: pointer; color: #2563eb; margin-top: 10px; }

/* Phase 7: timetable grid */
.timetable-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 16px; }
.timetable-day { background: #fff; border-radius: 8px; padding: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.timetable-day h4 { margin: 0 0 10px; border-bottom: 1px solid #e5e7eb; padding-bottom: 6px; }
.timetable-slot { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px; margin-bottom: 8px; font-size: .85rem; }
.timetable-slot form { margin-top: 4px; }

/* Phase 12: responsive layout pass for tablet/mobile widths */
@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; }
    .sidebar nav { display: flex; flex-wrap: wrap; }
    .sidebar nav a { padding: 8px 12px; font-size: .85rem; }
    .nav-group { width: 100%; padding: 10px 12px 2px; }
    .app-header { flex-direction: column; align-items: stretch; gap: 10px; }
    .app-content { padding: 14px; }
    .form-grid { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
    .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
    .toolbar form { flex-wrap: wrap; }
    .inline-form { flex-direction: column; align-items: stretch; }
    .inline-form input, .inline-form select, .inline-form button { width: 100%; }
    .form-card, .form-card-wide { max-width: 100%; padding: 16px; }
    .data-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
    .timetable-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .auth-card { width: 90%; padding: 24px; }
    .stat-cards { grid-template-columns: 1fr 1fr; }
}
