/* ============================================================
   Golfinity Admin — modern admin-styling.
   Färdig design med custom palette, Inter typografi, sidebar
   navigation och redesigned cards/tables/forms.
   Använder Bootstrap som bas men overridrar mer eller mindre allt.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Färgpalett — Golfinity-grönt + neutral grå-skala */
    --color-bg:           #f6f7f9;
    --color-surface:      #ffffff;
    --color-surface-alt:  #f9fafb;
    --color-border:       #e5e7eb;
    --color-border-soft:  #f1f3f5;

    --color-text:         #0f172a;
    --color-text-muted:   #64748b;
    --color-text-soft:    #94a3b8;

    --color-primary:      #10b981;
    --color-primary-700:  #059669;
    --color-primary-50:   #ecfdf5;

    --color-danger:       #ef4444;
    --color-danger-50:    #fef2f2;
    --color-warning:      #f59e0b;
    --color-warning-50:   #fffbeb;
    --color-info:         #3b82f6;
    --color-info-50:      #eff6ff;

    --shadow-xs:  0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-sm:  0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md:  0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg:  0 12px 32px rgba(15, 23, 42, 0.08);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --sidebar-width: 240px;
    --header-height: 64px;
}

/* ---------- Reset & base ---------- */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    background: var(--color-bg);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--color-primary-700); text-decoration: none; }
a:hover { color: var(--color-primary); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.01em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }

/* ---------- App-shell layout ---------- */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* When not authenticated, suppress the sidebar slot so login fills the screen */
.app-shell--no-nav {
    grid-template-columns: 1fr;
}

/* ---------- Sidebar ---------- */

.sidebar {
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    padding: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 10;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--color-border-soft);
    text-decoration: none !important;
    color: var(--color-text) !important;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.sidebar-brand .brand-dot {
    width: 10px;
    height: 10px;
    background: var(--color-primary);
    border-radius: 50%;
    display: inline-block;
    margin-right: 10px;
}

.sidebar-nav {
    list-style: none;
    padding: 1rem 0.75rem;
    margin: 0;
    flex: 1;
}

.sidebar-nav li { margin-bottom: 2px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted) !important;
    text-decoration: none !important;
    font-weight: 500;
    font-size: 0.92rem;
    transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-nav a:hover {
    background: var(--color-surface-alt);
    color: var(--color-text) !important;
}

.sidebar-nav a.active {
    background: var(--color-primary-50);
    color: var(--color-primary-700) !important;
}

.sidebar-nav a.active svg { stroke: var(--color-primary-700); }

.sidebar-nav svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    flex-shrink: 0;
}

.sidebar-user {
    padding: 1rem;
    border-top: 1px solid var(--color-border-soft);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user .avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-700) 100%);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-email {
    font-size: 0.82rem;
    color: var(--color-text);
    font-weight: 500;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-user .logout-link {
    color: var(--color-text-soft) !important;
    font-size: 0.78rem;
    text-decoration: none !important;
}
.sidebar-user .logout-link:hover { color: var(--color-danger) !important; }

/* ---------- Main content ---------- */

.app-main {
    padding: 2rem 2.5rem 3rem;
    max-width: 1400px;
    width: 100%;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1 { margin: 0; }
.page-header .actions { display: flex; gap: 8px; }

/* ---------- Cards ---------- */

.card,
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.25rem 1.4rem;
}

.stat-card .stat-label {
    color: var(--color-text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-card .stat-label svg {
    width: 16px; height: 16px;
    color: var(--color-text-soft);
}

.stat-card .stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.stat-card .stat-suffix { font-size: 1.1rem; font-weight: 500; color: var(--color-text-muted); }

.stat-card .stat-sub {
    font-size: 0.78rem;
    color: var(--color-text-soft);
    margin-top: 4px;
}

.stat-card.stat-card--accent {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-700) 100%);
    color: #fff;
    border: none;
}
.stat-card.stat-card--accent .stat-label,
.stat-card.stat-card--accent .stat-sub { color: rgba(255,255,255,0.85); }
.stat-card.stat-card--accent .stat-value { color: #fff; }
.stat-card.stat-card--accent .stat-label svg { color: rgba(255,255,255,0.85); }

/* ---------- Tables ---------- */

.data-table-wrapper {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

table.data-table thead th {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

table.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border-soft);
    vertical-align: middle;
}

table.data-table tbody tr:last-child td { border-bottom: none; }

table.data-table tbody tr:hover { background: var(--color-surface-alt); }

table.data-table tfoot th,
table.data-table tfoot td {
    padding: 14px 16px;
    background: var(--color-surface-alt);
    font-weight: 600;
    border-top: 1px solid var(--color-border);
    border-bottom: none;
}

table.data-table .text-end,
table.data-table th.text-end,
table.data-table td.text-end {
    text-align: right;
}

table.data-table .num {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.club-name { font-weight: 600; color: var(--color-text); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
    text-decoration: none !important;
    line-height: 1.4;
}

.btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }

.btn-primary,
.btn-success {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover,
.btn-success:hover {
    background: var(--color-primary-700);
    border-color: var(--color-primary-700);
    color: #fff;
}

.btn-outline-primary,
.btn-outline-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-outline-primary:hover,
.btn-outline-secondary:hover {
    border-color: var(--color-primary);
    color: var(--color-primary-700);
    background: var(--color-primary-50);
}

.btn-outline-success {
    background: var(--color-surface);
    color: var(--color-primary-700);
    border-color: var(--color-primary);
}
.btn-outline-success:hover {
    background: var(--color-primary-50);
    color: var(--color-primary-700);
}

.btn-outline-warning {
    background: var(--color-surface);
    color: var(--color-warning);
    border-color: #fde68a;
}
.btn-outline-warning:hover {
    background: var(--color-warning-50);
    color: #b45309;
}

.btn-outline-danger {
    background: var(--color-surface);
    color: var(--color-danger);
    border-color: #fecaca;
}
.btn-outline-danger:hover {
    background: var(--color-danger-50);
    color: var(--color-danger);
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-text-muted);
    padding: 8px 12px;
}
.btn-link:hover { color: var(--color-text); text-decoration: none; }

.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn-xs { padding: 3px 8px; font-size: 0.78rem; }

/* ---------- Forms ---------- */

.form-label {
    font-weight: 500;
    color: var(--color-text);
    font-size: 0.9rem;
    margin-bottom: 6px;
    display: block;
}

.form-control,
input.form-control,
input[type="text"].form-control,
input[type="email"].form-control,
input[type="password"].form-control,
input[type="number"].form-control,
textarea.form-control {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 0.95rem;
    color: var(--color-text);
    width: 100%;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.form-text {
    color: var(--color-text-muted);
    font-size: 0.82rem;
    margin-top: 4px;
}

.input-group { display: flex; }
.input-group .form-control { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group-text {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 9px 12px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ---------- Alerts ---------- */

.alert {
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    padding: 14px 16px;
    margin-bottom: 1rem;
    font-size: 0.92rem;
}

.alert-success {
    background: var(--color-primary-50);
    border-color: #a7f3d0;
    color: #065f46;
}
.alert-warning {
    background: var(--color-warning-50);
    border-color: #fde68a;
    color: #92400e;
}
.alert-danger {
    background: var(--color-danger-50);
    border-color: #fecaca;
    color: #991b1b;
}
.alert-info {
    background: var(--color-info-50);
    border-color: #bfdbfe;
    color: #1e40af;
}

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
}

.badge.text-bg-success { background: var(--color-primary-50); color: var(--color-primary-700); }
.badge.text-bg-warning { background: var(--color-warning-50); color: #92400e; }
.badge.text-bg-danger  { background: var(--color-danger-50);  color: #991b1b; }
.badge.text-bg-light   { background: var(--color-surface-alt); color: var(--color-text-muted); }

/* ---------- Code chip / API key chip ---------- */

.code-chip {
    display: inline-block;
    background: #0f172a;
    color: #d1fae5;
    font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
    font-size: 0.85rem;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    word-break: break-all;
    user-select: all;
    width: 100%;
}

code, pre {
    font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
}

pre.api-key-display {
    background: #0f172a;
    color: #d1fae5;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    word-break: break-all;
    user-select: all;
    margin: 12px 0 16px;
}

/* ---------- Login layout (unauthenticated) ---------- */

.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 0%, rgba(16, 185, 129, 0.12), transparent 40%),
        radial-gradient(circle at 80% 100%, rgba(59, 130, 246, 0.10), transparent 40%),
        var(--color-bg);
    padding: 2rem;
}

.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    padding: 2.5rem 2rem;
}

.auth-card .auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 1.5rem;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}

.auth-card .auth-brand .brand-dot {
    width: 12px;
    height: 12px;
    background: var(--color-primary);
    border-radius: 50%;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 1.4rem;
}

.auth-card .auth-sub {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.75rem;
}

/* ---------- Misc ---------- */

.text-muted { color: var(--color-text-muted) !important; }
.text-soft { color: var(--color-text-soft); }
.divider { border-top: 1px solid var(--color-border-soft); margin: 1.25rem 0; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
}

.empty-state svg {
    width: 48px; height: 48px;
    margin-bottom: 1rem;
    color: var(--color-text-soft);
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: relative;
        height: auto;
    }
    .sidebar-nav {
        display: flex;
        gap: 4px;
        padding: 0.5rem;
        overflow-x: auto;
    }
    .sidebar-nav li { margin: 0; }
    .sidebar-nav a { white-space: nowrap; }
    .sidebar-user { display: none; }
    .app-main { padding: 1.25rem 1rem; }
    .stat-card .stat-value { font-size: 1.5rem; }
}

/* Hide leftover Bootstrap navbar utilities since we no longer use them */
.navbar { display: none !important; }
footer.footer { display: none !important; }
