/* ==========================================================================
   ClassBank - Shared Stylesheet
   ========================================================================== */

/* 1. Base
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    background-color: #f5f5f5;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* 2. Typography
   ========================================================================== */

h1 {
    margin-bottom: 1.5rem;
}

.auth-body h1 {
    text-align: center;
}

.balance-card h1 {
    text-align: center;
}

.profile-header h1 {
    text-align: center;
}

h2 {
    margin-top: 0;
    margin-bottom: 1rem;
}

/* 3. Layout
   ========================================================================== */

/* Pages with banner (most authenticated pages) */
.page-body {
    padding-top: 70px;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Auth/public pages without banner */
.auth-body {
    padding-top: 2rem;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Width modifiers */
.container-narrow   { max-width: 400px; width: 100%; }
.container-small    { max-width: 500px; width: 100%; }
.container-medium   { max-width: 600px; width: 100%; }
.container-wide     { max-width: 800px; width: 100%; }
.container-xl       { max-width: 900px; width: 100%; }

/* 4. Cards
   ========================================================================== */

.card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.card h2 {
    margin-top: 0;
    margin-bottom: 1rem;
}

/* Form-centric card (auth pages, centered form pages) */
.form-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 100%;
}

/* 5. Forms
   ========================================================================== */

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

textarea {
    height: 100px;
    resize: vertical;
}

textarea.textarea-tall {
    height: 150px;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary   { background-color: #007bff; }
.btn-primary:hover { background-color: #0056b3; }

.btn-secondary { background-color: #6c757d; }
.btn-secondary:hover { background-color: #565e64; }

.btn-success   { background-color: #28a745; }
.btn-success:hover { background-color: #218838; }

.btn-danger    { background-color: #dc3545; }
.btn-danger:hover { background-color: #c82333; }

.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.85rem; }

.btn-full { width: 100%; }

.btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

/* Default button (unstyled buttons get primary treatment) */
button {
    padding: 0.75rem;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

button:hover {
    background-color: #0056b3;
}

/* Radio group */
.radio-group {
    margin-bottom: 1rem;
}

.radio-group label {
    display: inline;
    font-weight: normal;
    margin-right: 1.5rem;
}

.radio-group input[type="radio"] {
    margin-right: 0.25rem;
}

/* Checkbox rows */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.checkbox-row input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.checkbox-row label {
    font-weight: normal;
    margin: 0;
}

/* 6. Alerts
   ========================================================================== */

.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
}

.alert-success {
    background: #d4edda;
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
}

.alert-info {
    background: #cce5ff;
    color: #004085;
}

/* 7. Tables
   ========================================================================== */

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

.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid #dee2e6;
    font-size: 0.85rem;
    color: #666;
    text-transform: uppercase;
    background: #f9f9f9;
    font-weight: 600;
}

.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #eee;
}

.data-table td a {
    color: #007bff;
    text-decoration: none;
}

.data-table td a:hover {
    text-decoration: underline;
}

.data-table td a.btn {
    color: white;
    text-decoration: none;
}

/* Results table (full cell borders, used for create_student results) */
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.results-table th,
.results-table td {
    border: 1px solid #ddd;
    padding: 0.5rem;
    text-align: left;
    font-size: 0.9rem;
}

.results-table th {
    background: #f8f9fa;
}

.results-table td.mono {
    font-family: monospace;
    letter-spacing: 0.05em;
}

/* 8. Lists
   ========================================================================== */

.item-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.item-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

.item-list li:last-child {
    border-bottom: none;
}

.item-list a {
    text-decoration: none;
    color: #007bff;
    font-weight: bold;
}

.item-list a:hover {
    text-decoration: underline;
}

.item-list .teacher-name {
    font-size: 0.85rem;
    color: #666;
    margin-left: 0.5rem;
}

/* 9. Badges
   ========================================================================== */

/* Role badges (solid color) */
.role-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-right: 0.25rem;
    color: white;
}

.role-student { background: #2196F3; }
.role-teacher { background: #4CAF50; }
.role-banker  { background: #FF9800; }

/* Transaction status badges */
.status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
}

.status-pending   { background: #fff3cd; color: #856404; }
.status-complete  { background: #d4edda; color: #155724; }
.status-cancelled { background: #f8d7da; color: #721c24; }

/* Transaction amount colors */
.amount-positive { color: #28a745; font-weight: bold; }
.amount-negative { color: #dc3545; font-weight: bold; }

/* Balance display */
.balance { font-weight: 600; font-family: monospace; }
.balance-positive { color: #2e7d32; }
.balance-negative { color: #c62828; }

.balance-badge {
    background: #28a745;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: bold;
}

/* Result status colors (manage_transactions) */
.status-success { color: #28a745; }
.status-skipped { color: #dc3545; }

/* 10. Banner / Navigation
   ========================================================================== */

.site-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background-color: #007bff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.site-banner a.brand {
    color: white;
    font-size: 1.25rem;
    font-weight: bold;
    text-decoration: none;
}

.site-banner .nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-banner .nav-links a {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.site-banner .nav-links a:hover {
    background-color: rgba(255,255,255,0.2);
    text-decoration: none;
}

.site-banner .nav-links a.nav-active {
    background-color: rgba(255,255,255,0.25);
    font-weight: 600;
}

.site-banner .nav-links a.logout-btn {
    background-color: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.4);
}

.site-banner .nav-links a.logout-btn:hover {
    background-color: rgba(255,255,255,0.3);
}

.site-banner .nav-links .nav-balance {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.3rem 0.6rem;
    background-color: rgba(255,255,255,0.15);
    border-radius: 4px;
}

.balance-display {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 1rem;
}

/* Class selector in navbar */
.class-selector-form {
    display: flex;
    align-items: center;
}

.class-selector {
    width: auto;
    margin-bottom: 0;
    padding: 0.3rem 0.5rem;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    max-width: 200px;
}

.class-selector:hover {
    background: rgba(255,255,255,0.25);
}

.class-selector option {
    color: #333;
    background: white;
}

/* 11. Utilities
   ========================================================================== */

.table-responsive {
    overflow-x: auto;
}

.back-link {
    display: inline-block;
    margin-top: 1.5rem;
}

.back-link-center {
    display: block;
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.empty {
    color: #999;
    font-style: italic;
}

.hint {
    font-size: 0.85rem;
    color: #666;
    margin-top: -0.75rem;
    margin-bottom: 1rem;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.links {
    margin-top: 1rem;
}

.links a {
    color: #007bff;
    text-decoration: none;
}

.links a:hover {
    text-decoration: underline;
}

.char-count {
    text-align: right;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 1rem;
}

.version-info {
    text-align: right;
    font-size: 0.85rem;
    color: #999;
    margin-bottom: 1rem;
}

.divider {
    border: none;
    border-top: 1px solid #ddd;
    margin: 1.5rem 0;
}

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

/* 12. Page-Specific Components
   ========================================================================== */

/* Balance card (index.php student dashboard) */
.balance-card {
    text-align: center;
    padding: 2rem;
}

.balance-amount {
    font-size: 2.5rem;
    font-weight: bold;
    color: #28a745;
    margin: 0.5rem 0;
}

.balance-label {
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Page header with inline balance (shop.php) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0;
    text-align: left;
}

/* Profile header card */
.profile-header {
    text-align: center;
    padding: 2rem 1.5rem;
}

.profile-name {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.profile-email {
    color: #666;
    font-size: 0.9rem;
}

.bio-text {
    line-height: 1.6;
    color: #333;
    white-space: pre-wrap;
}

.bio-empty {
    color: #999;
    font-style: italic;
}

.role-list {
    margin-bottom: 1rem;
}

/* Product grid (shop.php) */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.product-card {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.product-price {
    font-size: 1.25rem;
    color: #28a745;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.product-description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    flex-grow: 1;
}

.product-stock {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 0.75rem;
}

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

.buy-form input[type="number"] {
    width: 60px;
    padding: 0.4rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    margin-bottom: 0;
}

.buy-btn {
    padding: 0.4rem 1rem;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    width: auto;
}

.buy-btn:hover {
    background-color: #0056b3;
}

.buy-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

/* Tab UI (manage_transactions.php) */
.tab-buttons {
    display: flex;
    gap: 0;
    margin-bottom: 0;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 1rem;
    color: #495057;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    width: auto;
}

.tab-btn.active {
    background: white;
    color: #007bff;
    font-weight: bold;
    border-bottom: 2px solid white;
    margin-bottom: -1px;
    position: relative;
    z-index: 1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.card.tabbed {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: 1px solid #dee2e6;
}

/* Autocomplete suggestions (add_students.php) */
.autocomplete-row {
    position: relative;
    margin-bottom: 0.5rem;
}

.autocomplete-row input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    z-index: 10;
    display: none;
    max-height: 200px;
    overflow-y: auto;
}

.suggestions div {
    padding: 0.5rem;
    cursor: pointer;
}

.suggestions div:hover {
    background-color: #e9ecef;
}

/* Multi-row form (create_student.php) */
.form-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-row input {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.form-row input[name="first_names[]"] { flex: 1; }
.form-row input[name="last_names[]"]  { flex: 1; }
.form-row input[name="emails[]"]      { flex: 1.5; }

.header-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    font-weight: bold;
    font-size: 0.85rem;
    color: #555;
}

.header-row span:nth-child(1) { flex: 1; }
.header-row span:nth-child(2) { flex: 1; }
.header-row span:nth-child(3) { flex: 1.5; }

.button-row {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* CSV upload section (create_student.php) */
.csv-section {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 1rem;
}

.csv-section label {
    font-weight: bold;
    display: block;
    margin-bottom: 0.5rem;
}

.csv-section input[type="file"] {
    margin-bottom: 0.5rem;
}

.csv-section p {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

/* Results box (create_student.php) */
.results-box {
    background: #e8f4fd;
    border: 1px solid #bee5eb;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.results-box p {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    color: #666;
}

/* Student list for user restriction (create_product.php) */
.student-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.5rem;
    margin-bottom: 1rem;
    display: none;
}

.student-list .checkbox-row {
    padding: 0.25rem 0;
}

.student-list-empty {
    color: #999;
    font-style: italic;
    padding: 0.5rem;
}

/* Toggle groups (create_product.php) */
#quantity-group {
    display: none;
}

#user-restrict-group {
    display: none;
}

/* Class detail description (class.php) */
.description {
    margin-top: 1rem;
    line-height: 1.6;
}

.text-muted { color: #999; font-size: 0.9rem; }

/* Must-reset body text */
.text-muted-body {
    color: #555;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* Action bar (class.php teacher links) */
.action-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

/* Consume/refund inline forms (inventory.php) */
.consume-form {
    display: inline;
}

.consume-qty {
    width: 60px;
}

/* Profile teacher action buttons */
.profile-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

/* Product type badges (shop.php) */
.type-consumable { background: #e3f2fd; color: #1565c0; }
.type-permanent  { background: #e8f5e9; color: #2e7d32; }

/* Bulk action bar (class_transactions.php) */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.bulk-bar .selected-label {
    color: #555;
    font-size: 0.9rem;
    margin-left: auto;
}

/* Filter row (class_transactions.php) */
.filter-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.filter-row .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-row label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
    margin: 0;
}

.filter-row input,
.filter-row select {
    margin: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.9rem;
}

.filter-row input[type="text"] { width: 160px; }
.filter-row input[type="date"] { width: 140px; }

/* Pagination (class_transactions.php) */
.txn-pagination {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
    margin-top: 0.75rem;
}

.txn-pagination .page-info { color: #555; font-size: 0.9rem; margin-right: 0.5rem; }

th.col-check { width: 2rem; }

/* Scheduled Jobs (manage_jobs.php)
   ========================================================================== */

.cron-explainer {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
}

.cron-explainer p { margin: 0.5rem 0; }
.cron-explainer ul { margin: 0.25rem 0 0.5rem 1.25rem; padding: 0; }

.cron-fields-diagram {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0.75rem 0;
}

.cron-field-label {
    display: flex;
    gap: 0.5rem;
}

.cron-field-box {
    background: #1565c0;
    color: #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    min-width: 100px;
}

.cron-field-ranges {
    gap: 0.5rem;
    font-size: 0.78rem;
    color: #555;
}

.cron-field-ranges span {
    min-width: 100px;
    padding: 0 0.6rem;
    text-align: center;
}

.cron-help-list {
    margin: 0.25rem 0 0.5rem 1.25rem;
    padding: 0;
}

.cron-help-list li { margin: 0.2rem 0; }

.cron-help-list code,
.cron-explainer code {
    background: #e8eaf0;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.88rem;
}

.cron-input-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.cron-input-row .form-group {
    flex: 1;
    min-width: 80px;
}

.cron-field-input {
    font-family: monospace;
    font-size: 1rem;
}

.cron-preview {
    font-family: monospace;
    font-size: 1rem;
    background: #e8eaf0;
    border: 1px solid #c5cae9;
    border-radius: 4px;
    padding: 0.4rem 0.75rem;
    margin-bottom: 1rem;
    color: #1a237e;
    letter-spacing: 0.03em;
}

.form-row-inline {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.form-row-inline .form-group { flex: 1; min-width: 160px; }

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-top: 0.25rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
    cursor: pointer;
}

.optional { color: #888; font-size: 0.85rem; font-weight: 400; }

.badge-credit  { background: #2e7d32; color: #fff; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
.badge-debit   { background: #c62828; color: #fff; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
.badge-active  { background: #1565c0; color: #fff; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
.badge-inactive{ background: #9e9e9e; color: #fff; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }

.job-inactive td { opacity: 0.55; }

.action-cell { white-space: nowrap; }

/* Footer
   ========================================================================== */

.site-footer {
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
    color: #888;
    font-size: 0.85rem;
    border-top: 1px solid #e0e0e0;
}
