/*
 * RAIA - AI Assistant Flow Manager
 * Main Stylesheet - Dark Mode + Raiffeisen Bank Colors
 */

/* =============================================================================
   CSS Variables - Design System
   ============================================================================= */

:root {
    /* Primary Accent - Raiffeisen Yellow */
    --rb-yellow: #FFE600;
    --rb-yellow-hover: #FFD000;
    --rb-yellow-active: #E6CF00;
    --rb-yellow-text: #1A1A1A;  /* Text on yellow background */
    
    /* Dark Mode Backgrounds */
    --bg-primary: #121212;
    --bg-secondary: #1A1A1A;
    --bg-surface: #1E1E1E;
    --bg-elevated: #252525;
    --bg-hover: #2A2A2A;
    --bg-active: #333333;
    
    /* Text Colors */
    --text-primary: #FFFFFF;
    --text-secondary: #B0B0B0;
    --text-muted: #6B6B6B;
    --text-disabled: #4A4A4A;
    
    /* Semantic Colors */
    --success: #4CAF50;
    --success-bg: rgba(76, 175, 80, 0.15);
    --error: #F44336;
    --error-bg: rgba(244, 67, 54, 0.15);
    --warning: #FF9800;
    --warning-bg: rgba(255, 152, 0, 0.15);
    --info: #2196F3;
    --info-bg: rgba(33, 150, 243, 0.15);
    
    /* Borders */
    --border-color: #333333;
    --border-light: #404040;
    --border-focus: var(--rb-yellow);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* =============================================================================
   Reset & Base Styles
   ============================================================================= */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--rb-yellow);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--rb-yellow-hover);
}

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

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    color: var(--text-secondary);
}

.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--text-primary);
}

.text-yellow {
    color: var(--rb-yellow);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary Button - Yellow */
.btn-primary {
    background: var(--rb-yellow);
    color: var(--rb-yellow-text);
}

.btn-primary:hover:not(:disabled) {
    background: var(--rb-yellow-hover);
}

.btn-primary:active:not(:disabled) {
    background: var(--rb-yellow-active);
}

/* Secondary Button - Outlined */
.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Danger Button */
.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #D32F2F;
}

/* Warning Button */
.btn-warning {
    background: var(--warning);
    color: #1A1A1A;
}

.btn-warning:hover:not(:disabled) {
    background: #F57C00;
}

/* Button Sizes */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

/* Icon Button */
.btn-icon {
    padding: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
}

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

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-fast);
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.card-body {
    color: var(--text-secondary);
}

.card-footer {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: var(--space-sm);
}

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

.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--rb-yellow);
    box-shadow: 0 0 0 3px rgba(255, 230, 0, 0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge-yellow {
    background: var(--rb-yellow);
    color: var(--rb-yellow-text);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-error {
    background: var(--error-bg);
    color: var(--error);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

/* =============================================================================
   Layout
   ============================================================================= */

/* App Layout - Main container for sidebar + content */
.app-layout {
    display: flex;
    min-height: calc(100vh - 60px); /* Subtract navbar height */
}

.main-content {
    flex: 1;
    overflow: auto;
}

/* Full-width layout (no sidebar) */
.main-content.full-width {
    width: 100%;
}

.container {
    width: 100%;
    padding: 0 var(--space-lg);
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* =============================================================================
   Utilities
   ============================================================================= */

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Loading Spinner */
.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border-color);
    border-top-color: var(--rb-yellow);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =============================================================================
   HTMX Loading States
   ============================================================================= */

.htmx-request .htmx-indicator {
    opacity: 1;
}

.htmx-indicator {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

/* =============================================================================
   Auth Pages Layout
   ============================================================================= */

.auth-header-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.auth-header-bar .navbar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.auth-header-bar .logo-icon {
    font-size: 1.75rem;
}

.auth-header-bar .logo-text {
    background: linear-gradient(135deg, var(--rb-yellow) 0%, var(--rb-yellow-hover) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-main {
    min-height: calc(100vh - 60px);
    background: var(--bg-primary);
}

/* =============================================================================
   Logo Icon Images
   ============================================================================= */

.logo-icon-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.bot-icon-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.stat-icon-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.empty-icon-img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: var(--space-md);
}

.tab-icon-img {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 4px;
}

.table-icon-img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 8px;
}

.node-icon-img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.context-icon-img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

/* =============================================================================
   Bot Card Component
   ============================================================================= */

.bot-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.bot-card:hover {
    border-color: var(--rb-yellow);
    box-shadow: var(--shadow-md);
}

.bot-card-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.bot-icon {
    font-size: 2rem;
    line-height: 1;
}

.bot-card .bot-info {
    flex: 1;
}

.bot-card .bot-name {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.bot-card .bot-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.bot-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
}

.bot-status.active {
    background: var(--success-bg);
    color: var(--success);
}

.bot-status.inactive {
    background: var(--bg-elevated);
    color: var(--text-muted);
}

.bot-card-stats {
    display: flex;
    gap: var(--space-xl);
    padding: var(--space-md) 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-md);
}

.bot-card-stats .stat {
    display: flex;
    flex-direction: column;
}

.bot-card-stats .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.bot-card-stats .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bot-card-actions {
    display: flex;
    gap: var(--space-sm);
}

/* =============================================================================
   Responsive - Mobile First
   ============================================================================= */

/* Small devices (phones, 576px and down) */
@media (max-width: 576px) {
    html {
        font-size: 14px;
    }
    
    .container {
        padding: 0 var(--space-md);
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
    
    .btn-lg {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }
    
    .card {
        padding: var(--space-md);
    }
    
    .page-header {
        flex-direction: column;
        gap: var(--space-md);
    }
    
    .page-header .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    /* Bot card on mobile */
    .bot-card-stats {
        gap: var(--space-md);
        flex-wrap: wrap;
    }
    
    .bot-card-stats .stat-value {
        font-size: 1.25rem;
    }
    
    /* Tables on mobile */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Medium devices (tablets, 768px and down) */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }
    
    .page-header .header-actions {
        width: 100%;
    }
    
    /* Grid adjustments */
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    
    /* Hide certain elements on mobile */
    .hide-mobile {
        display: none !important;
    }
    
    /* Show mobile-only elements */
    .show-mobile {
        display: block !important;
    }
}

/* Large devices (desktops, 992px and down) */
@media (max-width: 992px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =============================================================================
   Modal Overlay & Container
   ============================================================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    z-index: 100000;
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    padding: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

/* Print styles */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .sidebar-overlay {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
}
