/* =========================================================
   ClassPing Admin Web
   Basic styles for the Django Template admin application.
   ========================================================= */


/* ---------------------------------------------------------
   Global
   --------------------------------------------------------- */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f5f8f6;
    color: #17231f;
}


/* ---------------------------------------------------------
   Sidebar
   --------------------------------------------------------- */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;

    width: 240px;
    height: 100vh;

    background: #ffffff;
    border-right: 1px solid #e6ece8;

    padding: 24px 16px;
}

.sidebar-logo {
    font-size: 24px;
    font-weight: 700;

    padding: 0 12px 32px;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar nav a {
    display: block;

    padding: 12px;

    border-radius: 8px;

    color: #17231f;
    text-decoration: none;
}

.sidebar nav a:hover {
    background: #dff3eb;
}

.sidebar-group summary {
    padding: 12px;
    border-radius: 8px;
    color: #17231f;
    cursor: pointer;
    list-style-position: inside;
}

.sidebar-group[open] summary,
.sidebar-group summary:hover {
    background: #dff3eb;
}

.sidebar-group a {
    margin-left: 12px;
    padding: 9px 12px !important;
    font-size: 14px;
}


/* ---------------------------------------------------------
   Main content
   --------------------------------------------------------- */

.main-content {
    margin-left: 240px;
    min-height: 100vh;
}


/* ---------------------------------------------------------
   Topbar
   --------------------------------------------------------- */

.topbar {
    height: 72px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 32px;

    background: #ffffff;
    border-bottom: 1px solid #e6ece8;
}

.topbar h1 {
    margin: 0;
    font-size: 20px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-menu a {
    color: #147d64;
    text-decoration: none;
}


/* ---------------------------------------------------------
   Content
   --------------------------------------------------------- */

.content {
    padding: 32px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    margin-bottom: 24px;
}

.page-header h2 {
    margin: 8px 0;
}

.text-muted {
    color: #718079;
}


/* ---------------------------------------------------------
   Cards
   --------------------------------------------------------- */

.card {
    background: #ffffff;

    border: 1px solid #e6ece8;
    border-radius: 12px;

    padding: 24px;

    /* Keep wide tables and other overflow inside the card boundary. */
    min-width: 0;
}

.table-wrapper {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
}


/* ---------------------------------------------------------
   Buttons
   --------------------------------------------------------- */

.btn {
    display: inline-block;

    padding: 10px 16px;

    border-radius: 8px;

    border: 1px solid #d5ded9;

    background: #ffffff;

    color: #17231f;

    text-decoration: none;

    cursor: pointer;
}

.btn-primary {
    background: #147d64;
    border-color: #147d64;
    color: #ffffff;
}

.btn-small {
    padding: 6px 12px;
    font-size: 14px;
}

.btn-full {
    width: 100%;
}


/* ---------------------------------------------------------
   Table
   --------------------------------------------------------- */

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

.data-table th,
.data-table td {
    text-align: left;

    padding: 14px 12px;

    border-bottom: 1px solid #e6ece8;
}

.data-table th {
    color: #718079;
    font-size: 14px;
}


/* ---------------------------------------------------------
   Empty state
   --------------------------------------------------------- */

.empty-state {
    text-align: center;
    padding: 48px 20px;
}

.empty-state h3 {
    margin-bottom: 8px;
}


/* ---------------------------------------------------------
   Login
   --------------------------------------------------------- */

.login-page {
    min-height: 100vh;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;

    background: #ffffff;

    border: 1px solid #e6ece8;
    border-radius: 16px;

    padding: 32px;

    box-shadow: 0 12px 36px rgba(29, 50, 42, 0.08);
}

.login-header {
    text-align: center;

    margin-bottom: 32px;
}

.login-header h1 {
    margin-bottom: 8px;
}

.login-header p {
    margin: 0;
    color: #718079;
}


/* ---------------------------------------------------------
   Forms
   --------------------------------------------------------- */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;

    margin-bottom: 8px;

    font-weight: 600;
}

.form-group input {
    width: 100%;

    padding: 12px 14px;

    border: 1px solid #d5ded9;
    border-radius: 8px;

    font-size: 16px;
}

.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d5ded9;
    border-radius: 8px;
    background: #fff;
    font: inherit;
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.field-errors {
    color: #a33a3a;
    margin: 6px 0 0;
}

.help-text {
    display: block;
    margin-top: 6px;
    color: #718079;
    font-size: 14px;
}


/* ---------------------------------------------------------
   Alerts
   --------------------------------------------------------- */

.alert {
    padding: 12px 16px;

    border-radius: 8px;

    margin-bottom: 20px;
}

.alert-error {
    background: #fde8e8;
    color: #a33a3a;
}

.alert-success {
    background: #dff3eb;
    color: #14634f;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
    margin-bottom: 20px;
}

.filter-bar .form-group {
    margin: 0;
    min-width: 180px;
}

.filter-bar input,
.filter-bar select {
    padding: 9px 11px;
    border: 1px solid #d5ded9;
    border-radius: 6px;
    font: inherit;
}

.form-actions,
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.danger-button {
    color: #a33a3a;
    border-color: #e5bcbc;
}

.detail-section {
    margin-top: 24px;
}

.detail-section h3 {
    margin-bottom: 8px;
}

.form-card {
    max-width: 820px;
}

.sidebar {
    overflow-y: auto;
}

@media (max-width: 1000px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid #e6ece8;
    }

    .sidebar-logo {
        padding-bottom: 16px;
    }

    .sidebar nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sidebar-group {
        grid-column: 1 / -1;
    }

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

    .topbar {
        min-height: 72px;
        height: auto;
        gap: 12px;
        padding: 14px 18px;
    }

    .content {
        padding: 20px 16px;
        overflow-x: hidden;
    }

    .card {
        overflow: hidden;
    }

    .card:has(> .data-table) {
        overflow-x: auto;
    }

    .data-table {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
    }

    .data-table th,
    .data-table td {
        padding: 10px 6px;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .data-table td:last-child .btn,
    .data-table td:last-child form {
        display: block;
        width: 100%;
        margin: 0 0 6px;
    }

    .data-table td:last-child form button {
        width: 100%;
    }

    .page-header {
        gap: 12px;
        flex-wrap: wrap;
    }
}


/* ---------------------------------------------------------
   Detail
   --------------------------------------------------------- */

.detail-row {
    display: flex;

    padding: 16px 0;

    border-bottom: 1px solid #e6ece8;
}

.detail-label {
    width: 200px;

    color: #718079;
    font-weight: 600;
}

.back-link {
    color: #147d64;
    text-decoration: none;
}

/* ---------------------------------------------------------
   Status badges
   --------------------------------------------------------- */

.status {
    display: inline-block;

    padding: 4px 10px;

    border-radius: 999px;

    font-size: 13px;
    font-weight: 600;
}

.status-active {
    background: #dff3eb;
    color: #147d64;
}

.status-inactive {
    background: #eeeeee;
    color: #718079;
}

/* ---------------------------------------------------------
   Form actions
   --------------------------------------------------------- */

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;

    margin-top: 24px;
    padding-top: 24px;

    border-top: 1px solid #e6ece8;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;

    cursor: pointer;
}

.checkbox-label input {
    width: auto !important;
}

.alert ul {
    margin: 0;
    padding-left: 20px;
}

/* ---------------------------------------------------------
   Detail page
   --------------------------------------------------------- */

.section-card {
    margin-top: 24px;
}

.section-header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    margin-bottom: 20px;
}

.section-header h3 {
    margin: 0 0 6px;
}

.section-header p {
    margin: 0;
}

.detail-grid {
    display: grid;

    grid-template-columns: repeat(2, 1fr);

    gap: 24px;
}

.detail-item {
    display: flex;
    flex-direction: column;

    gap: 6px;
}

.detail-label {
    color: #718079;
    font-size: 14px;
}

/* Danger button */

.btn-danger {
    background: #dc5a5a;
    color: white;
    border: 1px solid #dc5a5a;
}

.btn-danger:hover {
    background: #c94747;
    border-color: #c94747;
}

.pagination {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.detail-actions {
    margin-top: 16px;
}

.form-inline-record {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 12px 0;
    padding: 16px;
}

.guardian-record {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
}

.guardian-choice,
.guardian-fields,
.guardian-settings {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
}

.guardian-new-toggle {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .45rem;
    align-items: center;
}

.guardian-new-toggle .help-text {
    grid-column: 2;
}

.guardian-details {
    border-top: 1px solid var(--border-color, #e5e7eb);
    padding-top: 1rem;
}

.guardian-details h4 {
    margin: 0 0 .75rem;
}
.select-search {
  width: 100%;
  margin-bottom: 4px;
}

.select-search-results {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #cbd5e1;
  background: #fff;
  position: relative;
  z-index: 5;
}

.select-search-option {
  display: block;
  width: 100%;
  border: 0;
  background: #fff;
  padding: 7px 10px;
  text-align: left;
  cursor: pointer;
}

.select-search-option:hover {
  background: #eef2ff;
}

.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card strong { display: block; font-size: 28px; margin-top: 8px; }
