/* Ryan Review Center — reusable components */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s, box-shadow .15s, transform .05s;
    text-decoration: none;
    line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--police-blue); color: var(--white); }
.btn-primary:hover { background: #0a3480; }

.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: #d9970a; }

.btn-secondary { background: var(--white); color: var(--navy); border-color: var(--border); }
.btn-secondary:hover { background: var(--mist); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }

.btn-success { background: var(--success); color: var(--white); }

.btn-ghost { background: transparent; color: var(--slate); }
.btn-ghost:hover { background: var(--mist); }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* Cards */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
}
.card + .card { margin-top: var(--space-4); }
.card-title { margin-bottom: var(--space-3); }

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-3);
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-value {
    font-family: var(--font-head);
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--navy);
}
.stat-card .stat-label { color: var(--slate); font-size: 0.85rem; }
.stat-card.gold { border-top: 3px solid var(--gold); }
.stat-card.blue { border-top: 3px solid var(--police-blue); }

/* Forms */
.form-group { margin-bottom: var(--space-4); }
.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--navy);
    margin-bottom: var(--space-2);
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    color: var(--ink);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--police-blue);
    box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.15);
}
.form-textarea { min-height: 90px; resize: vertical; }
.form-hint { font-size: 0.8rem; color: var(--muted); margin-top: var(--space-1); }
.form-check { display: flex; align-items: center; gap: var(--space-2); }
.form-check input { width: 18px; height: 18px; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-muted { background: var(--mist); color: var(--slate); }
.badge-gold { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1d4ed8; }

/* Alerts */
.alert {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 0.9rem;
    margin-bottom: var(--space-4);
    border: 1px solid transparent;
}
.alert-danger { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.alert-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.alert-warning { background: #fffbeb; color: #b45309; border-color: #fde68a; }

/* Spinner */
.spinner {
    width: 22px; height: 22px;
    border: 3px solid rgba(11, 61, 145, 0.25);
    border-top-color: var(--police-blue);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner-light { border-color: rgba(255,255,255,.4); border-top-color: #fff; }
.loading-center { display: flex; justify-content: center; padding: var(--space-6); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--white); }
.table { width: 100%; border-collapse: collapse; min-width: 520px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.table th { background: var(--mist); color: var(--navy); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table .actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Responsive: stack table rows into cards on phones.
   Cells use data-label="Header" to show their column name. */
@media (max-width: 640px) {
    .table-wrap { overflow-x: visible; border: none; background: transparent; }
    .table { min-width: 0; border-collapse: separate; border-spacing: 0; }
    .table thead { display: none; }
    .table tr {
        display: block; background: var(--white);
        border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow-sm); margin-bottom: var(--space-3); padding: var(--space-2) 0;
    }
    .table td {
        display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
        border-bottom: 1px solid var(--mist); text-align: right; padding: 10px 14px;
    }
    .table tr td:last-child { border-bottom: none; }
    .table td::before {
        content: attr(data-label);
        font-weight: 600; color: var(--navy); text-align: left; white-space: nowrap;
    }
    .table td.actions { justify-content: flex-end; flex-wrap: wrap; }
    .table td.actions::before { align-self: center; }
}

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(10, 31, 68, 0.55);
    display: flex; align-items: center; justify-content: center;
    padding: var(--space-4);
    z-index: 100;
}
.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 560px;
    max-height: 90vh; overflow-y: auto;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; }
.modal-body { padding: var(--space-5); }
.modal-footer {
    display: flex; justify-content: flex-end; gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
}
.modal-close {
    background: none; border: none; font-size: 1.5rem; line-height: 1;
    color: var(--slate); cursor: pointer;
}

/* Toasts */
#toast-container {
    position: fixed; top: calc(var(--topbar-h) + 12px); right: 16px;
    z-index: 200; display: flex; flex-direction: column; gap: var(--space-2);
    max-width: 90vw;
}
.toast {
    background: var(--navy); color: var(--white);
    padding: 12px 16px; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); font-size: 0.9rem;
    animation: toast-in .2s ease-out;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Empty state */
.empty {
    text-align: center; padding: var(--space-6); color: var(--muted);
}
