/* ============================================================
   MuscleAge Admin System Styles
   Shared across admin-login.php, admin.php, super-admin.php
   ============================================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
    --dark: #1e293b;
    --light: #f8fafc;
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 60px -10px rgba(0,0,0,0.1);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--gray-800);
    background: var(--gray-100);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

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

.login-card {
    background: var(--white);
    border-radius: var(--radius-2xl);
    padding: 48px 40px;
    box-shadow: var(--shadow-xl);
}

.logo-area {
    text-align: center;
    margin-bottom: 32px;
}

.logo-area img {
    height: 48px;
    margin-bottom: 12px;
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

.logo-area p {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-top: 4px;
}

/* ============================================================
   FORMS
   ============================================================ */

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

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-family: var(--font-sans);
    color: var(--gray-800);
    background: var(--white);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.form-input::placeholder {
    color: var(--gray-300);
}

.form-input--error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn--primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 6px -1px rgb(37 99 235 / 0.2);
}

.btn--primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgb(37 99 235 / 0.3);
}

.btn--primary:active {
    transform: translateY(0);
}

.btn--secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 2px solid var(--gray-200);
}

.btn--secondary:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.btn--danger {
    background: var(--danger);
    color: var(--white);
}

.btn--danger:hover {
    background: #dc2626;
}

.btn--success {
    background: var(--success);
    color: var(--white);
}

.btn--success:hover {
    background: #059669;
}

.btn--sm {
    padding: 6px 14px;
    font-size: 0.75rem;
}

.btn--lg {
    width: 100%;
    padding: 16px;
    font-size: 1rem;
}

.btn--logout {
    padding: 8px 16px;
    background: transparent;
    color: var(--gray-500);
    border: 1px solid var(--gray-700);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.btn--logout:hover {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}

/* ============================================================
   ALERTS
   ============================================================ */

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert--error {
    background: var(--danger-light);
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert--success {
    background: var(--success-light);
    color: #047857;
    border: 1px solid #a7f3d0;
}

.alert--warning {
    background: var(--warning-light);
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert--info {
    background: var(--primary-light);
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ============================================================
   HEADER
   ============================================================ */

.app-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-header--dark {
    background: var(--gray-900);
    border-bottom: 1px solid var(--gray-800);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.app-header--dark .logo {
    color: var(--white);
}

.logo-icon {
    height: 36px;
    width: auto;
    object-fit: contain;
}

.logo-badge {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-500);
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: 32px;
}

.nav-list a {
    text-decoration: none;
    color: var(--gray-600);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 8px 0;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
}

.nav-list a:hover,
.nav-list a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.app-header--dark .nav-list a {
    color: var(--gray-500);
}

.app-header--dark .nav-list a:hover,
.app-header--dark .nav-list a.active {
    color: var(--white);
    border-bottom-color: var(--primary);
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.user-avatar--purple {
    background: var(--purple);
    color: var(--white);
}

.user-details {
    text-align: right;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-800);
}

.app-header--dark .user-name {
    color: var(--white);
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: capitalize;
}

/* ============================================================
   MAIN CONTAINER
   ============================================================ */

.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
}

.main-container--wide {
    max-width: 1400px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--gray-700);
    margin-bottom: 32px;
}

/* ============================================================
   STATS GRID
   ============================================================ */

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

.stats-grid--6 {
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

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

.stat-card--compact {
    padding: 20px;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.stat-label--small {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
}

.stat-value--small {
    font-size: 1.75rem;
}

.stat-value--success { color: var(--success); }
.stat-value--warning { color: var(--warning); }
.stat-value--danger { color: var(--danger); }
.stat-value--purple { color: var(--purple); }

/* ============================================================
   TABS
   ============================================================ */

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--gray-200);
    padding: 4px;
    border-radius: var(--radius-lg);
    width: fit-content;
}

.tab-btn {
    padding: 10px 24px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
}

.tab-btn.active {
    background: var(--white);
    color: var(--gray-900);
    box-shadow: var(--shadow-sm);
}

.tab-btn:hover:not(.active) {
    color: var(--gray-800);
}

.tab-panel {
    display: none;
}

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

/* ============================================================
   TABLES
   ============================================================ */

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.table-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

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

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

th {
    background: var(--gray-100);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    font-size: 0.9375rem;
}

tr:hover td {
    background: var(--gray-50);
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge--low { background: var(--success-light); color: var(--success); }
.badge--moderate { background: var(--warning-light); color: var(--warning); }
.badge--high { background: var(--danger-light); color: var(--danger); }
.badge--role { background: var(--primary-light); color: var(--primary); }
.badge--role-admin { background: var(--purple); color: var(--white); }

/* ============================================================
   RISK INDICATORS
   ============================================================ */

.risk-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.risk-dot--low { background: var(--success); }
.risk-dot--moderate { background: var(--warning); }
.risk-dot--high { background: var(--danger); }

.age-diff {
    font-weight: 600;
}

.age-diff--positive { color: var(--danger); }
.age-diff--negative { color: var(--success); }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot--active { background: var(--success); }
.status-dot--inactive { background: var(--gray-300); }

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--gray-900);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--gray-700);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--gray-200);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-800);
}

/* ============================================================
   DB STATUS
   ============================================================ */

.db-status {
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    font-size: 0.875rem;
}

.db-status--error {
    background: var(--danger-light);
    color: var(--danger);
}

.db-status--success {
    background: var(--success-light);
    color: var(--success);
}

/* ============================================================
   SECURITY BADGE
   ============================================================ */

.security-badge {
    text-align: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

.security-badge span {
    font-size: 0.75rem;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ============================================================
   BACK LINK
   ============================================================ */

.back-link {
    text-align: center;
    margin-top: 24px;
}

.back-link a {
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.back-link a:hover {
    color: var(--primary);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
    .stats-grid--6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-grid,
    .stats-grid--6 {
        grid-template-columns: repeat(2, 1fr);
    }

    .nav-list {
        display: none;
    }

    .user-details {
        display: none;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    th, td {
        padding: 12px 8px;
        font-size: 0.8rem;
    }

    .login-card {
        padding: 32px 24px;
    }

    .modal-content {
        padding: 24px;
    }
}

@media (max-width: 480px) {
    .stats-grid,
    .stats-grid--6 {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 28px 20px;
        border-radius: var(--radius-lg);
    }

    .logo-area h1 {
        font-size: 1.25rem;
    }

    .main-container {
        padding: 24px 16px;
    }

    .page-title {
        font-size: 1.5rem;
    }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   FOCUS VISIBLE
   ============================================================ */

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
