/* FitTrack Pro — Dedicated Admin Portal Styling */
:root {
    --bg-dark: #090d16;
    --bg-card: #121824;
    --bg-card-hover: #192233;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.25);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);
    --success: #10b981;
    --warning: #f59e0b;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

/* Layout Grid */
.admin-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    background: #0d121e;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.admin-sidebar-header {
    margin-bottom: 2rem;
}

.admin-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-logo-icon {
    font-size: 1.8rem;
    background: rgba(139, 92, 246, 0.15);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.admin-logo h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
}

.admin-badge-subtitle {
    font-size: 0.72rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.admin-nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.admin-nav-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.admin-nav-item a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.admin-nav-item.active a {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(59, 130, 246, 0.15));
    color: #ffffff;
    border: 1px solid rgba(139, 92, 246, 0.4);
    box-shadow: 0 4px 14px var(--primary-glow);
}

.nav-badge {
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 20px;
    margin-left: auto;
}

.admin-sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-return-app {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 0.65rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-return-app:hover {
    background: rgba(59, 130, 246, 0.25);
    color: white;
}

.btn-admin-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.25);
    padding: 0.65rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-admin-logout:hover {
    background: rgba(239, 68, 68, 0.25);
    color: white;
}

/* Main Workspace */
.admin-main {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.admin-header-title h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.text-muted {
    color: var(--text-muted);
}

.admin-header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

/* Cards & Tables */
.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: rgba(139, 92, 246, 0.4);
}

.kpi-icon {
    font-size: 1.8rem;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
}

.kpi-val {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}

.kpi-lbl {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Table Design */
.table-responsive {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.admin-table th {
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.admin-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Buttons */
.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.btn-danger-sm {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

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

.btn-warning-sm {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-warning-sm:hover {
    background: var(--warning);
    color: white;
}

.loading-spinner {
    text-align: center;
    padding: 3rem;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.btn-primary-sm {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    border: none;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary-sm:hover {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Styled Select / Dropdown Elements */
select.form-control,
select,
.admin-select {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    background-color: #121824;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.92rem;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

select.form-control:focus,
select:focus,
.admin-select:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #192233;
    box-shadow: 0 0 0 3px var(--primary-glow);
}

select option,
select optgroup {
    background-color: #121824;
    color: #f8fafc;
    padding: 0.6rem 1rem;
}

/* Custom Checkbox & Radio styling */
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--primary);
    cursor: pointer;
}

/* Modal Dialog */
.admin-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.admin-modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.25s ease-out;
    overflow: hidden;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.admin-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.admin-modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.admin-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.admin-modal-close:hover {
    color: white;
}

.admin-modal-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.admin-modal-body::-webkit-scrollbar {
    width: 6px;
}
.admin-modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
.admin-modal-body::-webkit-scrollbar-thumb {
    background: rgba(168, 85, 247, 0.4);
    border-radius: 4px;
}
.admin-modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(168, 85, 247, 0.7);
}

.admin-mobile-toggle-btn {
    display: none;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* Sidebar Backdrop Overlay for Mobile */
.admin-sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.admin-sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* Tablet & Mobile Breakpoints */
@media (max-width: 900px) {
    .admin-mobile-toggle-btn {
        display: flex;
    }

    .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        height: 100vh;
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        z-index: 9999;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
        overflow-y: auto;
    }

    .admin-sidebar.show {
        left: 0;
    }

    .admin-main {
        padding: 1rem;
        gap: 1rem;
    }
}

/* Specific Mobile Portrait Format Optimization (smartphones <= 600px width) */
@media (max-width: 600px) {
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .admin-header-user {
        width: 100%;
        justify-content: flex-start;
        padding-top: 0.5rem;
        border-top: 1px dashed var(--border-color);
    }

    .admin-header-title h2 {
        font-size: 1.2rem;
    }

    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        gap: 0.75rem;
    }

    .kpi-card {
        padding: 1.0rem;
        gap: 0.75rem;
    }

    .kpi-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .kpi-val {
        font-size: 1.3rem;
    }

    .admin-card {
        padding: 1rem;
    }

    /* Modal responsiveness in portrait format */
    .admin-modal-card {
        max-width: 95vw !important;
        max-height: 88vh !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        border-radius: var(--radius-md);
    }

    .admin-modal-body {
        padding: 1rem !important;
        flex: 1 !important;
        overflow-y: auto !important;
        min-height: 0 !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Stack multi-column forms into single column in portrait mode */
    form div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Table cells & buttons scaling for mobile portrait */
    .admin-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.82rem;
    }

    .admin-table th {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }

    .admin-table td[style*="display: flex"] {
        flex-wrap: wrap !important;
        gap: 0.35rem !important;
        justify-content: flex-start !important;
    }
}

/* Toast Notification System */
.admin-toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
    max-width: calc(100vw - 2rem);
}

.admin-toast {
    background: #121824;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    pointer-events: auto;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.admin-toast.toast-success {
    border-left: 4px solid var(--success);
}

.admin-toast.toast-danger {
    border-left: 4px solid var(--danger);
}

.admin-toast.toast-info {
    border-left: 4px solid var(--primary);
}

.admin-toast.toast-warning {
    border-left: 4px solid var(--warning);
}

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

/* Deleting element animation */
.row-deleting {
    background-color: rgba(239, 68, 68, 0.18) !important;
    opacity: 0 !important;
    transform: translateX(30px) !important;
    transition: all 0.35s ease-out !important;
}
