/* ========================================
   NACHHALL Ops - Design System
   ========================================

   This file implements a consistent design system with:
   - Montserrat font family
   - Golden ratio (φ = 1.618) based typography scale
   - iOS-style corner smoothing (squircle approximation)
   - NACHHALL brand colors

   Typography Scale (Golden Ratio):
   - 3xl: 2.618rem (41.89px) - Page titles
   - 2xl: 1.618rem (25.89px) - Section headers
   - xl:  1.25rem  (20px)    - Card titles
   - lg:  1.125rem (18px)    - Emphasized text
   - base: 1rem    (16px)    - Body text
   - sm:  0.875rem (14px)    - Secondary text
   - xs:  0.75rem  (12px)    - Captions, labels

   Corner Radius Scale (iOS smoothing via larger radii):
   - xs: 4px  - Small elements (badges, chips)
   - sm: 8px  - Buttons, inputs
   - md: 12px - Cards, dropdowns
   - lg: 16px - Modals, large cards
   - xl: 24px - Feature cards, login cards
   - full: 9999px - Pills, avatars

   ======================================== */

/* ========================================
   Font Face
   ======================================== */

@font-face {
    font-family: 'Montserrat';
    src: url('/static/fonts/Montserrat-VariableFont_wght.ttf') format('truetype-variations');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* ========================================
   Design Tokens (CSS Custom Properties)
   ======================================== */

:root {
    /* Font Family */
    --font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Typography Scale - Golden Ratio (φ = 1.618) */
    --text-3xl: 2.618rem;    /* 41.89px - Page titles */
    --text-2xl: 1.618rem;    /* 25.89px - Section headers */
    --text-xl: 1.25rem;      /* 20px - Card titles */
    --text-lg: 1.125rem;     /* 18px - Emphasized text */
    --text-base: 1rem;       /* 16px - Body text */
    --text-sm: 0.875rem;     /* 14px - Secondary text */
    --text-xs: 0.75rem;      /* 12px - Captions, labels */

    /* Font Weights */
    --font-light: 300;
    --font-regular: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* Line Heights - Golden Ratio based */
    --leading-tight: 1.25;
    --leading-normal: 1.618;  /* Golden ratio */
    --leading-relaxed: 1.75;

    /* Letter Spacing */
    --tracking-tight: -0.02em;
    --tracking-normal: 0;
    --tracking-wide: 0.02em;

    /* Corner Radius - iOS-style smooth corners */
    /* Using larger radii to approximate squircle smoothness */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* NACHHALL Brand Colors */
    --nachhall-primary: #0E9A9F;
    --nachhall-primary-light: #22B3B8;
    --nachhall-primary-dark: #078084;

    /* Semantic Colors */
    --color-danger: #DC3545;
    --color-danger-dark: #BB2D3B;
    --color-danger-light: #F8D7DA;
    --color-success: #198754;
    --color-warning: #FFC107;

    /* Layout */
    --sidebar-width: 250px;
    --navbar-height: 56px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* ========================================
   Icons (Heroicons)
   ======================================== */

.icon {
    width: 1.25rem;
    height: 1.25rem;
    display: inline-block;
    vertical-align: -0.125em;
    flex-shrink: 0;
}

.icon-sm {
    width: 1rem;
    height: 1rem;
}

.icon-lg {
    width: 1.5rem;
    height: 1.5rem;
}

.icon-xl {
    width: 2rem;
    height: 2rem;
}

.icon-2xl {
    width: 3rem;
    height: 3rem;
}

/* ========================================
   Base Styles
   ======================================== */

* {
    font-family: var(--font-family);
}

body {
    font-family: var(--font-family);
    font-size: var(--text-base);
    font-weight: var(--font-regular);
    line-height: var(--leading-normal);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Typography Classes
   ======================================== */

h1, .h1 {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
}

h2, .h2 {
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
}

h3, .h3 {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
}

h4, .h4 {
    font-size: var(--text-lg);
    font-weight: var(--font-medium);
    line-height: var(--leading-normal);
}

h5, .h5 {
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    line-height: var(--leading-normal);
}

h6, .h6 {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    line-height: var(--leading-normal);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.text-3xl { font-size: var(--text-3xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-xl { font-size: var(--text-xl); }
.text-lg { font-size: var(--text-lg); }
.text-base { font-size: var(--text-base); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }

/* ========================================
   iOS Corner Smoothing
   ========================================
   True iOS "squircle" corners use a superellipse formula.
   CSS border-radius uses circular arcs, not superellipses.

   This approximation uses:
   1. Larger border-radius values
   2. Consistent application across all components
   3. The visual effect is close to iOS on most elements

   For pixel-perfect iOS corners, use a JS library like
   'figma-squircle' or SVG masks.
   ======================================== */

/* Apply smooth corners globally */
.card,
.btn,
.alert,
.badge,
.dropdown-menu,
.modal-content,
.toast,
.form-control,
.form-select,
.input-group > * {
    border-radius: var(--radius-md);
}

/* Small elements */
.badge,
.btn-sm {
    border-radius: var(--radius-sm);
}

/* Large elements */
.card-lg,
.modal-content {
    border-radius: var(--radius-lg);
}

/* Pills and avatars */
.rounded-pill,
.avatar {
    border-radius: var(--radius-full);
}

/* ========================================
   Layout - Sidebar and Main Content
   ======================================== */

/* Sidebar styling - Floating */
.sidebar {
    position: fixed;
    top: calc(var(--navbar-height) + 12px);
    left: 12px;
    bottom: 12px;
    width: var(--sidebar-width);
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.sidebar .nav-link {
    color: #495057;
    border-radius: var(--radius-sm);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.sidebar .nav-link:hover {
    background-color: #e9ecef;
    color: #212529;
}

.sidebar .nav-link.active {
    background-color: var(--nachhall-primary);
    color: white;
}

.sidebar .nav-link i {
    width: 1.25rem;
    text-align: center;
}

/* Main content wrapper */
.main-wrapper {
    min-height: 100vh;
    overflow-x: hidden;
}

/* When user is logged in (has sidebar) */
body.has-sidebar .main-wrapper {
    margin-left: calc(var(--sidebar-width) + 24px);
    margin-top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Responsive - hide sidebar on mobile */
@media (max-width: 991.98px) {
    .sidebar {
        top: 0;
    }

    body.has-sidebar .main-wrapper {
        margin-left: 0;
    }
}

/* ========================================
   Navbar
   ======================================== */

.navbar-brand {
    font-weight: var(--font-semibold);
    font-size: var(--text-lg);
    letter-spacing: var(--tracking-tight);
}

.navbar .nav-link {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

/* User dropdown */
.navbar .dropdown-menu {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 0.5rem;
}

.navbar .dropdown-item {
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.navbar .dropdown-item-text {
    font-size: var(--text-xs);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.navbar .dropdown-item-text .icon {
    flex-shrink: 0;
}

/* Header quick links */
.navbar .nav-link-icon {
    padding: 0.375rem;
    border-radius: var(--radius-sm);
    opacity: 0.7;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.navbar .nav-link-icon:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

.navbar .nav-link-icon .icon {
    display: block;
}

/* Fix profile dropdown icon alignment */
.navbar .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.navbar .dropdown-toggle .icon {
    vertical-align: baseline;
}

/* User menu dropdown */
.navbar .user-menu {
    min-width: 220px;
    max-width: 280px;
}

.navbar .user-menu .claim-item {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Sign out button - Red text, subtle hover */
.sign-out-btn {
    color: var(--color-danger) !important;
}

.sign-out-btn:hover {
    background-color: rgba(220, 53, 69, 0.08) !important;
    color: var(--color-danger) !important;
}

.sign-out-btn:active {
    background-color: rgba(220, 53, 69, 0.12) !important;
}

/* ========================================
   Login Page
   ======================================== */

.login-container {
    min-height: 100vh;
    padding: 2rem;
}

.login-container .card {
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.login-container h1 {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
}

/* ========================================
   Cards
   ======================================== */

.card {
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.card-header {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
}

.card-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
}

.card-text {
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
}

.rule-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.rule-card .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
}

.btn-lg {
    font-size: var(--text-base);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
}

.btn-sm {
    font-size: var(--text-xs);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
}

/* Primary button brand override */
.btn-primary {
    background-color: var(--nachhall-primary);
    border-color: var(--nachhall-primary);
}

.btn-primary:hover {
    background-color: var(--nachhall-primary-dark);
    border-color: var(--nachhall-primary-dark);
}

.btn-primary:active {
    background-color: var(--nachhall-primary-dark);
    border-color: var(--nachhall-primary-dark);
}

/* Button focus states */
.btn:focus {
    box-shadow: 0 0 0 0.25rem rgba(14, 154, 159, 0.25);
}

.btn-primary:focus {
    box-shadow: 0 0 0 0.25rem rgba(14, 154, 159, 0.25);
}

.btn-outline-danger:focus {
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

/* ========================================
   Forms
   ======================================== */

.form-label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.form-control,
.form-select {
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
}

.form-text {
    font-size: var(--text-xs);
}

/* ========================================
   Progress Bars
   ======================================== */

.progress {
    border-radius: var(--radius-xs);
    background-color: #e9ecef;
}

/* ========================================
   Alerts
   ======================================== */

.alert {
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
}

.alert-success {
    background-color: #d1e7dd;
    border-color: #badbcc;
}

/* IP display */
.alert code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.125rem 0.25rem;
    border-radius: var(--radius-xs);
    font-size: var(--text-xs);
}

/* ========================================
   Badges
   ======================================== */

.badge {
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    border-radius: var(--radius-sm);
    padding: 0.35em 0.65em;
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast {
    border-radius: var(--radius-md);
    border-width: 0 0 0 4px;
}

.toast-header {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.toast-body {
    font-size: var(--text-sm);
}

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

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

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

/* ========================================
   Tables
   ======================================== */

.table {
    font-size: var(--text-sm);
}

.table th {
    font-weight: var(--font-semibold);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

/* ========================================
   Home Page
   ======================================== */

.feature-card {
    transition: transform 0.2s;
    border-radius: var(--radius-lg);
}

.feature-card:hover {
    transform: translateY(-2px);
}

.feature-card .card-body {
    text-align: center;
    padding: 2rem;
}

.feature-card .feature-icon {
    font-size: var(--text-3xl);
    margin-bottom: 1rem;
    color: var(--nachhall-primary);
}

.feature-card .card-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
}

.feature-card.disabled {
    opacity: 0.5;
}

.feature-card.disabled:hover {
    transform: none;
}

/* Empty state */
.empty-state {
    font-size: var(--text-lg);
    color: #6c757d;
}

.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 768px) {
    :root {
        --text-3xl: 2rem;
        --text-2xl: 1.5rem;
        --text-xl: 1.125rem;
    }

    .card-body {
        padding: 1rem;
    }
}

/* ========================================
   Utility Classes
   ======================================== */

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Font weights */
.font-light { font-weight: var(--font-light); }
.font-regular { font-weight: var(--font-regular); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }
