/* ============================================================
   PREPAVOL - Layout principal
   ============================================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --topbar-height: 56px;
    --sidebar-bg: #1e2a3a;
    --sidebar-hover: #2c3e50;
    --sidebar-active: #34495e;
    --sidebar-text: #bdc3c7;
    --sidebar-text-active: #ffffff;
    --sidebar-header: #7f8c8d;
}

/* Layout */
body.app-layout {
    margin: 0;
    padding: 0;
    background: #f4f6f9;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: transform 0.3s ease;
}

.app-sidebar::-webkit-scrollbar {
    width: 4px;
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.sidebar-brand {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: var(--topbar-height);
}

.sidebar-brand img {
    height: 28px;
    width: auto;
}

.sidebar-brand .brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}

.sidebar-section {
    padding: 12px 0 4px;
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--sidebar-header);
    padding: 0 20px;
    margin-bottom: 4px;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav li a.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    border-left-color: #3498db;
}

.sidebar-nav li a i {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
}

.sidebar-nav li a .nav-badge {
    margin-left: auto;
    font-size: 0.7rem;
}

/* Main content area */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* Topbar */
.app-topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-left .club-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #2c3e50;
}

.topbar-left .club-icao {
    font-size: 0.8rem;
    color: #7f8c8d;
    background: #ecf0f1;
    padding: 2px 8px;
    border-radius: 4px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #7f8c8d;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    display: none;
}

.sidebar-toggle:hover {
    background: #f1f3f5;
}

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

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.topbar-user:hover {
    background: #f1f3f5;
}

.topbar-user .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #3498db;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
}

.topbar-user .user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.topbar-user .user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #2c3e50;
}

.topbar-user .user-role {
    font-size: 0.7rem;
    color: #7f8c8d;
}

/* Content */
.app-content {
    flex: 1;
    padding: 24px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}

.page-header .breadcrumb {
    font-size: 0.8rem;
    margin: 0;
    padding: 0;
}

/* Footer */
.app-footer {
    padding: 12px 24px;
    text-align: center;
    font-size: 0.75rem;
    color: #95a5a6;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

/* Mobile responsive */
@media (max-width: 991.98px) {
    .sidebar-toggle {
        display: block;
    }

    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1035;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .app-content {
        padding: 16px;
    }

    .app-topbar {
        padding: 0 12px;
    }

    .topbar-left .club-name {
        font-size: 0.85rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .table-card .card-header {
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .topbar-user .user-name,
    .topbar-user .user-role {
        display: none;
    }

    .topbar-user .fa-chevron-down {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .app-content {
        padding: 12px;
    }

    .stat-card {
        padding: 12px 14px;
    }

    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.1rem;
    }

    .table-card {
        border-radius: 6px;
    }

    .topbar-left .club-name {
        font-size: 0.8rem;
        max-width: 140px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar-left .club-icao {
        font-size: 0.7rem;
        padding: 1px 5px;
    }

    .table-card p,
    .table-card small {
        font-size: 0.8rem;
    }
}

/* Cards */
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-card .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: #7f8c8d;
}

.stat-card.d-block {
    display: block !important;
}

/* Tables */
.table-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.table-card .card-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 20px;
    font-weight: 600;
    margin: 0;
}

.table-card .list-group-flush .list-group-item {
    border-left: 0;
    border-right: 0;
}

.table-card .list-group-flush .list-group-item:first-child {
    border-top: 0;
}

.table-card .list-group-flush .list-group-item:last-child {
    border-bottom: 0;
}

/* Auth pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e2a3a 0%, #2c3e50 100%);
    padding: 20px;
}

.auth-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

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

.auth-card .auth-logo h2 {
    font-weight: 700;
    color: #2c3e50;
    margin: 8px 0 0;
}

.auth-card .auth-logo p {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Onboarding */
.onboarding-container {
    min-height: 100vh;
    background: #f4f6f9;
    padding: 40px 20px;
}

.onboarding-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    max-width: 700px;
    margin: 0 auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.mode-choice {
    display: flex;
    gap: 20px;
    margin-top: 24px;
}

.mode-choice .choice-card {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.mode-choice .choice-card:hover {
    border-color: #3498db;
    box-shadow: 0 4px 12px rgba(52,152,219,0.15);
}

.mode-choice .choice-card i {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.mode-choice .choice-card h4 {
    font-weight: 600;
    margin-bottom: 8px;
}

.mode-choice .choice-card p {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin: 0;
}

@media (max-width: 575.98px) {
    .mode-choice {
        flex-direction: column;
    }
}

/* Permissions grid */
.permissions-grid {
    display: grid;
    gap: 24px;
}

.permission-group {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.permission-group-header {
    background: #f8f9fa;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.permission-group-body {
    padding: 12px 16px;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.permission-item label {
    font-size: 0.875rem;
    cursor: pointer;
}

/* Support impersonation banner */
.support-banner {
    background: #dc3545;
    color: #fff;
    padding: 6px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    text-align: center;
}

body.support-mode .app-sidebar {
    top: 34px;
}

body.support-mode .app-topbar {
    top: 34px;
}

body.support-mode .app-main {
    padding-top: 34px;
}
