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

   This file implements a consistent design system with:
   - Montserrat font family
   - Golden ratio (φ = 1.618) based typography scale
   - NACHHALL brand colors
   - Design tokens as CSS custom properties

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

/* ========================================
   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 */
    --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);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Layout - Main Content
   ======================================== */

.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;
}

@media (max-width: 991.98px) {
    body.has-sidebar .main-wrapper {
        margin-left: 0;
    }
}

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

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

/* ========================================
   Rule Cards (Self-Service)
   ======================================== */

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

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

/* ========================================
   Empty State
   ======================================== */

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

/* ========================================
   Dual IP Detection Display
   ======================================== */

.detected-ips {
    display: flex;
    align-items: center;
    gap: var(--text-sm);
}

.ip-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
}

.ip-badge .ip-label {
    color: #6c757d;
    font-weight: var(--font-medium);
    text-transform: uppercase;
}

.ip-badge .ip-value {
    font-family: 'Consolas', 'Monaco', monospace;
    color: #212529;
    font-size: var(--text-xs);
    user-select: all;
    background: transparent;
    padding: 0;
}

.ip-badge.unavailable {
    opacity: 0.5;
}

.ip-badge.unavailable .ip-value {
    color: #6c757d;
}

@media (max-width: 576px) {
    .detected-ips {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .ip-badge .ip-value {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ========================================
   Drawer Panel (right-side)
   ======================================== */

#drawerBackdrop {
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

#drawerPanel {
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.drawer-header h5 {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drawer-close {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: #6c757d;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease;
    flex-shrink: 0;
}

.drawer-close:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: #212529;
}

/* Tabs - Tailwind underline style */
.drawer-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    background: none;
    border: none;
    border-top: none;
    border-left: none;
    border-right: none;
    border-bottom: 2px solid transparent;
    padding: 0.75rem 0.125rem;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: #6b7280;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease;
    flex-shrink: 0;
}

.drawer-tab:hover {
    color: #374151;
    border-bottom-color: #d1d5db;
}

.drawer-tab.active {
    color: var(--nachhall-primary);
    border-bottom-color: var(--nachhall-primary);
}

.drawer-tab .icon {
    margin-right: 0.375rem;
    margin-left: -0.125rem;
}

.drawer-header-delete {
    color: var(--color-danger);
    margin-right: 0.25rem;
}

.drawer-header-delete:hover {
    background-color: rgba(220, 53, 69, 0.08);
    color: var(--color-danger-dark);
}

.drawer-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

/* ========================================
   Clickable Table Rows
   ======================================== */

.table-clickable tbody tr {
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.table-clickable tbody tr:hover {
    background-color: rgba(14, 154, 159, 0.04);
}

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

.loading {
    opacity: 0.6;
    pointer-events: none;
}

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

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