/* ============================================================
   COMPONENTS.CSS — Buttons, Badges, Cards, Tables, Forms, Alerts
   ============================================================ */

/* ════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 18px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
    font-family: inherit;
    line-height: 1;
    user-select: none;
}

.btn:active { transform: translateY(1px); }

.btn-sm {
    height: 34px;
    padding: 0 12px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    height: 48px;
    padding: 0 24px;
    font-size: 15px;
    border-radius: var(--radius-lg);
}

/* Primary */
.btn-primary {
    background: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
}
.btn-primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    box-shadow: 0 4px 14px rgba(37,99,235,0.32);
    color: #ffffff;
}

/* Secondary */
.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover {
    background: #e8edf5;
    border-color: #c8d2e0;
    color: var(--color-text);
}

/* Outline Primary */
.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary-100);
}
.btn-outline:hover {
    background: var(--color-primary-soft);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Warning */
.btn-warning {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}
.btn-warning:hover {
    background: #fde68a;
    border-color: #fbbf24;
    color: #78350f;
}

/* Danger */
.btn-danger {
    background: var(--color-danger);
    color: #ffffff;
    border-color: var(--color-danger);
}
.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    box-shadow: 0 4px 12px rgba(220,38,38,0.28);
    color: #ffffff;
}

/* Success */
.btn-success {
    background: var(--color-success);
    color: #ffffff;
    border-color: var(--color-success);
}
.btn-success:hover {
    background: #15803d;
    border-color: #15803d;
    color: #ffffff;
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

/* ════════════════════════════════════════
   BADGES
   ════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

/* Status badges */
.badge-open, .badge-success {
    background: var(--color-success-bg);
    color: #15803d;
}

.badge-closed, .badge-danger {
    background: var(--color-danger-bg);
    color: #b91c1c;
}

.badge-draft, .badge-pending {
    background: #f1f5f9;
    color: #475569;
}

.badge-warning {
    background: var(--color-warning-bg);
    color: #b45309;
}

.badge-info {
    background: var(--color-info-bg);
    color: #0e7490;
}

.badge-primary {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

/* Bootstrap-compatible aliases */
.badge.bg-success { background: var(--color-success-bg) !important; color: #15803d !important; }
.badge.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }
.badge.bg-danger { background: var(--color-danger-bg) !important; color: #b91c1c !important; }
.badge.bg-warning { background: var(--color-warning-bg) !important; color: #b45309 !important; }
.badge.bg-primary { background: var(--color-primary-soft) !important; color: var(--color-primary) !important; }

/* ── Score badge ── */
.score-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
}
.score-badge.success { background: var(--color-success-bg); color: #15803d; }
.score-badge.warning { background: var(--color-warning-bg); color: #b45309; }
.score-badge.danger  { background: #f1f5f9; color: #64748b; }

/* Status badge (older compatibility) */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
}
.status-open   { background: var(--color-success-bg); color: #15803d; }
.status-closed { background: var(--color-danger-bg); color: #b91c1c; }
.status-draft  { background: #f1f5f9; color: #475569; }
.status-close  { background: var(--color-danger-bg); color: #b91c1c; }

/* ════════════════════════════════════════
   CARDS
   ════════════════════════════════════════ */
.page-card {
    background: var(--color-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.page-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--color-border-light);
    background: #fafbfc;
    flex-wrap: wrap;
}

.page-card-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--color-text);
    margin: 0;
}

.page-card-subtitle {
    font-size: 12.5px;
    color: var(--color-text-secondary);
    margin: 2px 0 0;
}

.page-card-body {
    padding: 20px 22px;
}

/* Stat Card */
.stat-card {
    background: var(--color-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-xl);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 22px;
}

.stat-icon.blue   { background: var(--color-primary-soft); color: var(--color-primary); }
.stat-icon.green  { background: var(--color-success-bg); color: var(--color-success); }
.stat-icon.amber  { background: var(--color-warning-bg); color: var(--color-warning); }
.stat-icon.red    { background: var(--color-danger-bg); color: var(--color-danger); }
.stat-icon.indigo { background: #ede9fe; color: #7c3aed; }
.stat-icon.cyan   { background: var(--color-info-bg); color: var(--color-info); }

.stat-body { min-width: 0; flex: 1; }

.stat-number {
    font-size: 30px;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1;
    display: block;
}

.stat-label {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 4px;
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

/* ════════════════════════════════════════
   TABLE
   ════════════════════════════════════════ */
.table-card {
    background: var(--color-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-light);
    background: #fafbfc;
    flex-wrap: wrap;
}

.table-card-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--color-text);
    margin: 0;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-light);
    white-space: nowrap;
    text-align: left;
}

.data-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--color-text);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: #f8fbff; }

/* ── Legacy table compatibility ── */
.custom-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.custom-table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-light);
    white-space: nowrap;
}
.custom-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--color-text);
    vertical-align: middle;
}
.custom-table tbody tr:hover { background: #f8fbff; }
.custom-table tbody tr:last-child td { border-bottom: none; }

.entity-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.entity-table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-light);
    white-space: nowrap;
}
.entity-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--color-text);
    vertical-align: middle;
}
.entity-table tbody tr:hover { background: #f8fbff; }
.entity-table tbody tr:last-child td { border-bottom: none; }
.entity-table-wrap { overflow-x: auto; }

.entity-index {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 600;
    text-align: center;
}

.entity-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: 12.5px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    color: var(--color-text);
}

.entity-main { font-weight: 600; color: var(--color-text); }

.entity-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.entity-pagination {
    padding: 16px 20px;
    border-top: 1px solid var(--color-border-light);
    background: #fafbfc;
}

.pagination-wrap { padding: 16px 20px; border-top: 1px solid var(--color-border-light); }

/* Table card compat */
.entity-card {
    background: var(--color-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 20px;
}

.entity-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-light);
    background: #fafbfc;
    flex-wrap: wrap;
}

.entity-card-title { font-size: 15px; font-weight: 800; color: var(--color-text); margin: 0; }
.entity-card-subtitle { font-size: 12px; color: var(--color-text-secondary); margin-top: 2px; }
.entity-card > form, .entity-card > .entity-card-form { padding: 20px; }

/* ════════════════════════════════════════
   FILTER BAR / SEARCH
   ════════════════════════════════════════ */
.filter-card {
    background: var(--color-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    margin-bottom: 16px;
}

.filter-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
}

.filter-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ════════════════════════════════════════
   FORMS
   ════════════════════════════════════════ */
.form-card {
    background: var(--color-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.form-section {
    padding: 22px;
    border-bottom: 1px solid var(--color-border-light);
}

.form-section:last-child { border-bottom: none; }

.form-section-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--color-text);
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--color-primary);
    display: inline-block;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 6px;
}

.form-control, .form-select {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    background: #ffffff;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 13.5px;
    color: var(--color-text);
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-control::placeholder { color: #94a3b8; }

textarea.form-control {
    height: auto;
    min-height: 90px;
    padding: 12px 14px;
    resize: vertical;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2364748b' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-col { flex: 1; min-width: 0; }

.form-error {
    font-size: 12px;
    color: var(--color-danger);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 22px;
    border-top: 1px solid var(--color-border-light);
    background: #fafbfc;
    flex-wrap: wrap;
}

/* Bootstrap compat */
.form-label.fw-semibold { font-weight: 700; }
input.form-control, select.form-select, textarea.form-control { /* inherits */ }

/* ════════════════════════════════════════
   ALERTS
   ════════════════════════════════════════ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 16px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 16px;
    border: 1px solid transparent;
    line-height: 1.5;
}

.alert-success {
    background: var(--color-success-bg);
    color: #166534;
    border-color: #bbf7d0;
}

.alert-danger {
    background: var(--color-danger-bg);
    color: #991b1b;
    border-color: #fecaca;
}

.alert-warning {
    background: var(--color-warning-bg);
    color: #92400e;
    border-color: #fde68a;
}

.alert-info {
    background: var(--color-info-bg);
    color: #0e4e6e;
    border-color: #bae6fd;
}

/* ── Alert dismissible ── */
.alert-dismissible { position: relative; padding-right: 40px; }
.btn-close {
    position: absolute;
    inset-block-start: 12px;
    inset-inline-end: 12px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0,0,0,0.08);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    border: none;
    color: inherit;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.btn-close:hover { opacity: 1; }

/* ════════════════════════════════════════
   PAGINATION (Bootstrap-compat)
   ════════════════════════════════════════ */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
}

.page-item .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    background: #fff;
    border: 1px solid var(--color-border);
    text-decoration: none;
    transition: 0.2s ease;
}

.page-item .page-link:hover {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    border-color: var(--color-primary-100);
}

.page-item.active .page-link {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.page-item.disabled .page-link {
    opacity: 0.45;
    pointer-events: none;
}

/* ════════════════════════════════════════
   MISC
   ════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 12px;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 6px;
}

.empty-state-text { font-size: 13.5px; }

/* Empty box (compat) */
.empty-box {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-secondary);
    font-size: 14px;
}

/* Entity page header */
.entity-page { padding: 0; }

.page-hero {
    margin-bottom: 22px;
}

.page-hero-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-text);
    margin: 0 0 6px;
}

.page-hero-subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin: 0;
}

/* Role badge */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
}

.role-admin   { background: #ede9fe; color: #6d28d9; }
.role-student { background: var(--color-primary-soft); color: var(--color-primary); }
.role-class   { background: var(--color-success-bg); color: var(--color-success); }
.role-advisor { background: var(--color-warning-bg); color: #b45309; }
.role-faculty { background: var(--color-info-bg); color: var(--color-info); }

/* ── Add to Bootstrap's missing utilities ── */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Timeline / Stepper */
.process-steps {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.process-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 100px;
    position: relative;
}

.process-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 18px;
    left: calc(50% + 18px);
    right: calc(-50% + 18px);
    height: 2px;
    background: var(--color-border);
}

.process-step.done::after { background: var(--color-success); }
.process-step.current::after { background: linear-gradient(90deg, var(--color-success), var(--color-border)); }

.step-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text-secondary);
    z-index: 1;
    position: relative;
    transition: 0.2s ease;
}

.process-step.done .step-dot {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
}

.process-step.current .step-dot {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.18);
}

.step-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-top: 8px;
    text-align: center;
    max-width: 90px;
    line-height: 1.3;
}

.process-step.done .step-label { color: var(--color-success); }
.process-step.current .step-label { color: var(--color-primary); }
