/* Premium GymSaaS Design System */
:root {
    /* Light Mode Tokens */
    --bg-main: #F7F6F2;
    --bg-surface: #FBFBF9;
    --bg-surface-hover: #F2F1EC;
    --text-main: #28251D;
    --text-muted: #7A7974;
    --accent-primary: #01696F;
    --accent-primary-hover: #015156;
    
    --status-success: #556B2F; /* Olive green */
    --status-success-bg: #E8EDE1;
    --status-warning: #D97736; /* Burnt amber */
    --status-warning-bg: #FBEFE6;
    --status-error: #722F37; /* Berry wine */
    --status-error-bg: #F4E5E7;

    --border-color: #E6E4DD;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 999px;

    --font-heading: 'General Sans', 'Satoshi', sans-serif;
    --font-body: 'Inter', 'Work Sans', sans-serif;
    
    --sidebar-width: 260px;
    --topbar-height: 72px;
    
    --transition-fast: 0.2s ease;
    --transition-base: 0.3s ease;
}

[data-theme="dark"] {
    --bg-main: #171614;
    --bg-surface: #1C1B19;
    --bg-surface-hover: #201F1D;
    --text-main: #CDCCCA;
    --text-muted: #797876;
    --accent-primary: #4F98A3;
    --accent-primary-hover: #5FB4C0;
    
    --status-success: #6B8E23;
    --status-success-bg: #1B2412;
    --status-warning: #E28743;
    --status-warning-bg: #2D1A0D;
    --status-error: #9E4244;
    --status-error-bg: #2A1012;

    --border-color: #2D2C2A;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    height: 100vh;
    transition: background-color var(--transition-base), color var(--transition-base);
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    z-index: 100;
}

.sidebar-header {
    margin-bottom: 32px;
    padding: 0 8px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 22px;
    color: var(--accent-primary);
}

.logo i {
    font-size: 28px;
}

.tenant-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background-color: var(--bg-surface-hover);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.tenant-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tenant-avatar {
    width: 36px;
    height: 36px;
    background-color: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
}

.tenant-details {
    display: flex;
    flex-direction: column;
}

.tenant-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.tenant-role {
    font-size: 11px;
    color: var(--text-muted);
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 4px;
}

.nav-item i {
    font-size: 20px;
}

.nav-item:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-main);
}

.nav-item.active {
    background-color: var(--status-success-bg);
    color: var(--accent-primary);
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
}

.sync-status.online {
    color: var(--status-success);
    background-color: var(--status-success-bg);
}

.sync-status.offline {
    color: var(--status-warning);
    background-color: var(--status-warning-bg);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

.search-bar {
    position: relative;
    width: 400px;
}

.search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding: 10px 16px 10px 48px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.search-bar input:focus {
    border-color: var(--accent-primary);
}

.search-shortcut {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    padding: 2px 6px;
    background-color: var(--bg-surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Views */
.views-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-header {
    margin-bottom: 32px;
}

.view-title {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.view-subtitle {
    color: var(--text-muted);
    font-size: 16px;
}

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

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

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

.stat-card {
    background-color: var(--bg-surface);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    overflow: hidden;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background-color: var(--status-success-bg);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.warning {
    background-color: var(--status-warning-bg);
    color: var(--status-warning);
}

.stat-icon.error {
    background-color: var(--status-error-bg);
    color: var(--status-error);
}

.stat-details {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--font-heading);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 24px;
}

/* Cards */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

.card-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    font-family: inherit;
}

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

.btn-primary:hover {
    background-color: var(--accent-primary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--bg-surface-hover);
}

.btn-text {
    background: transparent;
    color: var(--accent-primary);
    padding: 0;
}

.btn-icon-only {
    padding: 0;
    width: 36px;
    height: 36px;
    justify-content: center;
}

.btn-icon-only.btn-sm {
    width: 32px;
    height: 32px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.modal {
    background-color: var(--bg-surface);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease;
}

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

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

.modal-body {
    padding: 24px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: inherit;
    font-size: 15px;
    outline: none;
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

/* Action List (Collections Cockpit) */
.action-list {
    list-style: none;
}

.action-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.action-item:last-child {
    border-bottom: none;
}

.member-brief {
    display: flex;
    flex-direction: column;
}

.member-name {
    font-weight: 600;
    font-size: 14px;
}

.member-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* Timeline (Recent Activity) */
.timeline {
    list-style: none;
    position: relative;
    padding-left: 20px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-point {
    position: absolute;
    left: -20px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    border: 2px solid var(--bg-surface);
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.activity-title {
    font-size: 14px;
    font-weight: 500;
}

.activity-time {
    font-size: 11px;
    color: var(--text-muted);
}

.activity-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 32px;
    right: 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background-color: var(--bg-surface);
    color: var(--text-main);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--accent-primary);
    animation: toastSlideIn 0.3s ease;
}

.toast.error {
    border-left-color: var(--status-error);
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Empty States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.empty-state i {
    font-size: 64px;
    color: var(--border-color);
    margin-bottom: 24px;
}

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

/* Utilities */
.mt-4 { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Mobile Responsive */
@media (max-width: 768px) {
    #app { flex-direction: column; }
    
    .sidebar {
        width: 100%;
        flex-direction: row;
        padding: 8px 12px;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar-header, .tenant-selector, .sidebar-footer, .sync-status { display: none; }
    
    .nav-links {
        display: flex;
        gap: 4px;
        flex: none;
    }
    
    .nav-item { padding: 8px 12px; margin-bottom: 0; white-space: nowrap; }
    .nav-item span { display: none; }
    .nav-item i { font-size: 22px; }
    
    .topbar { padding: 0 16px; }
    .search-bar { width: 200px; }
    .search-shortcut { display: none; }
    
    .views-container { padding: 20px 16px; }
    .view-title { font-size: 24px; }
    
    .dashboard-grid { grid-template-columns: 1fr; }
    
    .form-row { grid-template-columns: 1fr; }
    
    .modal { max-width: 95vw; margin: 16px; }
}
