/* 
==============================================
UNIFIED DESIGN SYSTEM FOR SHOPIFY APP POSITION TRACKER
==============================================

This design system ensures consistency across all pages with:
- Modern, minimalistic, contrasting, and mobile-friendly design
- Unified color palette and typography
- Consistent component styling
- Responsive layout for all screen sizes

MANDATORY: All new components MUST use these design tokens
==============================================
*/

/* ========== SHOPIFY POLARIS DESIGN TOKENS ========== */
:root {
    /* Core Shopify Brand Colors */
    --primary: #008060;           /* Shopify green - primary actions */
    --primary-hover: #006144;     /* Darker green for hover states */
    --primary-pressed: #004c36;   /* Even darker for pressed states */
    --primary-light: #e6f3f0;     /* Light green backgrounds */
    --primary-lighter: #f0f9f7;   /* Very light green */
    
    /* Neutral Colors - Polaris Gray Scale */
    --surface: #FFFFFF;           /* Pure white background */
    --surface-neutral: #FAFBFB;   /* Lightest gray background */
    --surface-subdued: #F6F6F7;   /* Light gray background */
    --surface-disabled: #FAFBFB;  /* Disabled background */
    
    /* Text Colors - Polaris Text Scale */
    --text: #202223;              /* Primary text color */
    --text-subdued: #6D7175;      /* Secondary text */
    --text-disabled: #8C9196;     /* Disabled text */
    --text-on-color: #FFFFFF;     /* Text on colored backgrounds */
    
    /* Border Colors - Polaris Borders */
    --border: #D2D5D8;            /* Default border color */
    --border-subdued: #E1E3E5;    /* Subtle border */
    --border-strong: #8C9196;     /* Strong border */
    --border-on-color: #FFFFFF;   /* Border on colored backgrounds */
    
    /* Interactive Colors */
    --interactive: #006fbb;       /* Interactive elements */
    --interactive-hover: #085394; /* Interactive hover */
    --interactive-pressed: #033960; /* Interactive pressed */
    
    /* Status Colors - Polaris Semantic Colors */
    --success: #008060;           /* Success states */
    --success-light: #e6f3f0;     /* Success backgrounds */
    --warning: #ffc453;           /* Warning states */
    --warning-light: #fff5cc;     /* Warning backgrounds */
    --error: #d72c0d;             /* Error states */
    --error-light: #fdeae5;       /* Error backgrounds */
    --info: #006fbb;              /* Information states */
    --info-light: #e6f2ff;        /* Info backgrounds */
    
    /* Position Badge Colors - Updated for Polaris */
    --position-excellent: #008060; /* Positions 1-8 - Shopify green */
    --position-good: #ffc453;      /* Positions 9-16 - Warning yellow */
    --position-poor: #d72c0d;      /* Positions 17+ - Error red */
    --position-not-found: #6D7175; /* Not found - Subdued gray */
    
    /* Shadows - Polaris Shadow System */
    --shadow-xs: 0 1px 0 rgba(22, 29, 37, 0.05);
    --shadow-sm: 0 1px 0 rgba(22, 29, 37, 0.05), 0 1px 1px rgba(22, 29, 37, 0.1);
    --shadow-md: 0 4px 8px rgba(22, 29, 37, 0.1);
    --shadow-lg: 0 8px 16px rgba(22, 29, 37, 0.1);
    --shadow-xl: 0 12px 24px rgba(22, 29, 37, 0.15);
    
    /* Polaris Spacing Scale */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    
    /* Polaris Border Radius */
    --radius-sm: 3px;
    --radius: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;
    
    /* Polaris Typography Scale */
    --text-caption: 0.75rem;    /* 12px - Small text, captions */
    --text-body-sm: 0.8125rem;  /* 13px - Small body text */
    --text-body: 0.875rem;      /* 14px - Default body text */
    --text-subheading: 1rem;    /* 16px - Subheadings */
    --text-heading: 1.25rem;    /* 20px - Headings */
    --text-display-sm: 1.5rem;  /* 24px - Small display */
    --text-display-md: 1.75rem; /* 28px - Medium display */
    --text-display-lg: 2rem;    /* 32px - Large display */
    
    /* Polaris Font Weights */
    --font-regular: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 200ms ease-in-out;
    --transition-slow: 300ms ease-in-out;
}

/* ========== BASE STYLES ========== */

/* Reset and Base */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background-color: var(--surface-neutral);
    color: var(--text);
    line-height: 1.6;
    font-size: var(--text-body);
    font-weight: var(--font-regular);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== POLARIS TYPOGRAPHY UTILITIES ========== */

/* Text Sizes */
.text-caption { font-size: var(--text-caption); }
.text-body-sm { font-size: var(--text-body-sm); }
.text-body { font-size: var(--text-body); }
.text-subheading { font-size: var(--text-subheading); }
.text-heading { font-size: var(--text-heading); }
.text-display-sm { font-size: var(--text-display-sm); }
.text-display-md { font-size: var(--text-display-md); }
.text-display-lg { font-size: var(--text-display-lg); }

/* Font Weights */
.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); }

/* Text Colors */
.text-default { color: var(--text); }
.text-subdued { color: var(--text-subdued); }
.text-disabled { color: var(--text-disabled); }
.text-on-color { color: var(--text-on-color); }

/* Polaris Headings */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-semibold);
    line-height: 1.4;
    margin: 0 0 16px 0;
    color: var(--text);
    letter-spacing: -0.025em;
}

h1 { 
    font-size: var(--text-display-lg); 
    font-weight: var(--font-bold);
    line-height: 1.25;
    margin-bottom: 24px;
}

h2 { 
    font-size: var(--text-display-md); 
    font-weight: var(--font-semibold);
    line-height: 1.3;
    margin-bottom: 20px;
}

h3 { 
    font-size: var(--text-display-sm); 
    font-weight: var(--font-semibold);
    line-height: 1.35;
    margin-bottom: 16px;
}

h4 { 
    font-size: var(--text-heading); 
    font-weight: var(--font-semibold);
    line-height: 1.4;
    margin-bottom: 12px;
}

/* Polaris Page Layout - единый стиль для всех страниц */
.polaris-page-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subdued);
}

.polaris-page-header .d-flex {
    align-items: center;
    min-height: 60px;
}

.polaris-page-title {
    font-size: var(--text-display-md);
    font-weight: var(--font-semibold);
    line-height: 1.3;
    margin: 0;
    color: var(--text);
    letter-spacing: -0.02em;
}

.polaris-page-subtitle {
    font-size: var(--text-body);
    color: var(--text-subdued);
    margin: 4px 0 0 0;
    line-height: 1.5;
}

.polaris-page-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    align-self: center;
    margin: 0;
}

.polaris-page-content {
    max-width: 100%;
}

/* Empty State - единый стиль для пустых состояний */
.polaris-empty-state {
    text-align: center;
    padding: 64px 24px;
    background-color: var(--surface);
    border: 1px solid var(--border-subdued);
    border-radius: var(--radius-lg);
}

.polaris-empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    color: var(--text-subdued);
}

.polaris-empty-state-title {
    font-size: var(--text-heading);
    font-weight: var(--font-semibold);
    color: var(--text);
    margin: 0 0 8px 0;
}

.polaris-empty-state-description {
    font-size: var(--text-body);
    color: var(--text-subdued);
    margin: 0 0 24px 0;
    line-height: 1.5;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.polaris-empty-state-action {
    margin-top: 24px;
}

h5 { 
    font-size: var(--text-subheading); 
    font-weight: var(--font-medium);
    line-height: 1.5;
    margin-bottom: 8px;
}

h6 { 
    font-size: var(--text-body); 
    font-weight: var(--font-medium);
    line-height: 1.5;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Polaris Display Text */
.polaris-display-large {
    font-size: var(--text-display-lg);
    font-weight: var(--font-bold);
    line-height: 1.25;
    letter-spacing: -0.025em;
    color: var(--text);
}

.polaris-display-medium {
    font-size: var(--text-display-md);
    font-weight: var(--font-semibold);
    line-height: 1.3;
    letter-spacing: -0.02em;
    color: var(--text);
}

.polaris-heading {
    font-size: var(--text-heading);
    font-weight: var(--font-semibold);
    line-height: 1.4;
    color: var(--text);
}

.polaris-subheading {
    font-size: var(--text-subheading);
    font-weight: var(--font-medium);
    line-height: 1.5;
    color: var(--text);
}

.polaris-body {
    font-size: var(--text-body);
    font-weight: var(--font-regular);
    line-height: 1.6;
    color: var(--text);
}

.polaris-caption {
    font-size: var(--text-caption);
    font-weight: var(--font-regular);
    line-height: 1.5;
    color: var(--text-subdued);
}

/* ========== POLARIS BUTTONS ========== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    user-select: none;
    min-height: 36px;
}

/* Primary Button - Polaris Style */
.btn-primary {
    background: var(--primary) !important;
    color: var(--text-on-color) !important;
    border: 1px solid var(--primary) !important;
    box-shadow: 0 1px 0 rgba(22, 29, 37, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-hover) !important;
    color: #FFFFFF !important; /* Force white text on hover */
    border-color: var(--primary-hover) !important;
    box-shadow: 0 2px 4px rgba(22, 29, 37, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-primary:active {
    background: var(--primary-pressed) !important;
    color: #FFFFFF !important; /* Force white text on active state */
    border-color: var(--primary-pressed) !important;
    box-shadow: inset 0 1px 2px rgba(22, 29, 37, 0.15);
}

/* Secondary Button - Polaris Style */
.btn-secondary {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 1px 0 rgba(22, 29, 37, 0.05);
}

.btn-secondary:hover,
.btn-secondary:focus {
    background: var(--surface-subdued) !important;
    color: var(--text) !important;
    border-color: var(--border-strong) !important;
    box-shadow: 0 2px 4px rgba(22, 29, 37, 0.1);
}

/* Outline Buttons */
.btn-outline-primary {
    background: transparent !important;
    color: var(--primary) !important;
    border: 1px solid var(--primary) !important;
}

/* Note: hover styles for btn-outline-primary are defined in Legacy Compatibility section */

.btn-outline-secondary {
    background: transparent !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-strong) !important;
}

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

/* Danger Button - Polaris Style */
.btn-danger {
    background: var(--error) !important;
    color: var(--text-on-color) !important;
    border: 1px solid var(--error) !important;
    box-shadow: 0 1px 0 rgba(22, 29, 37, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-danger:hover,
.btn-danger:focus {
    background: #b71c1c !important;
    color: #FFFFFF !important; /* Force white text on hover for danger buttons */
    border-color: #b71c1c !important;
    box-shadow: 0 2px 4px rgba(22, 29, 37, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-outline-danger {
    background: transparent !important;
    color: var(--error) !important;
    border: 1px solid var(--error) !important;
}

.btn-outline-danger:hover {
    background: var(--error) !important;
    color: #FFFFFF !important; /* Force white text on hover for outline danger buttons */
    border-color: var(--error) !important;
}

/* Button Sizes - Polaris Style */
.btn-sm {
    padding: 0 12px;
    font-size: 13px;
    min-height: 32px;
}

.btn-lg {
    padding: 0 20px;
    font-size: 16px;
    min-height: 44px;
    font-weight: 500;
}

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

/* ========== POLARIS FORMS ========== */

.form-control {
    display: block;
    width: 100%;
    padding: 10px 12px;
    font-size: var(--text-body);
    font-weight: var(--font-regular);
    line-height: 1.4;
    color: var(--text);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.2s ease;
    min-height: 36px;
}

.form-control:focus {
    outline: none;
    border-color: var(--interactive);
    box-shadow: 0 0 0 2px rgba(0, 111, 187, 0.1);
}

.form-control::placeholder {
    color: var(--text-subdued);
    opacity: 1;
}

.form-control:disabled {
    background-color: var(--surface-disabled);
    color: var(--text-disabled);
    cursor: not-allowed;
    border-color: var(--border-subdued);
}

/* Polaris Form validation states */
.form-control.is-invalid {
    border-color: var(--error);
    box-shadow: 0 0 0 2px rgba(215, 44, 13, 0.1);
}

.form-control.is-valid {
    border-color: var(--success);
    box-shadow: 0 0 0 2px rgba(0, 128, 96, 0.1);
}

.invalid-feedback,
.valid-feedback {
    width: 100%;
    margin-top: 4px;
    font-size: var(--text-body-sm);
    font-weight: var(--font-medium);
}

.invalid-feedback {
    color: var(--error);
}

.valid-feedback {
    color: var(--success);
}

/* Polaris Form labels */
.form-label {
    margin-bottom: 8px;
    font-size: var(--text-body);
    font-weight: var(--font-medium);
    color: var(--text);
    display: block;
}

/* Filter labels should stay on one line */
.filter-section .form-label {
    white-space: nowrap;
    display: inline-block;
}

/* Form select */
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right var(--space-3) center;
    background-repeat: no-repeat;
    background-size: 16px 12px;
    padding-right: var(--space-8);
    appearance: none;
}

/* Input groups */
.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.input-group .form-control {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group .form-control:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 0;
}

.input-group .form-control:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group-text,
.input-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    line-height: 1.5;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    background-color: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Form switches */
.form-check {
    display: block;
    min-height: 1.5rem;
    padding-left: 1.5em;
    margin-bottom: var(--space-3);
}

.form-check-input {
    width: 1em;
    height: 1em;
    margin-top: 0.25em;
    margin-left: -1.5em;
    vertical-align: top;
    background-color: var(--surface);
    border: 1px solid var(--border);
    appearance: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.1);
}

.form-check-label {
    color: var(--text-primary);
    font-size: var(--text-sm);
    margin-left: var(--space-2);
}

/* Switch styles */
.form-switch .form-check-input {
    width: 2em;
    margin-left: -2.5em;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba(0,0,0,0.25)'/%3e%3c/svg%3e");
    background-position: left center;
    background-repeat: no-repeat;
    background-size: contain;
    border-radius: 2em;
}

.form-switch .form-check-input:checked {
    background-position: right center;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

/* ========== POLARIS CARDS ========== */

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 20px 24px 16px 24px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-subdued);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    font-weight: 600;
    color: var(--text);
    font-size: 16px;
}

.card-header h4,
.card-header h5,
.card-header h6 {
    margin-bottom: 0;
    font-weight: 600;
    color: var(--text);
}

.card-body {
    flex: 1 1 auto;
    padding: 20px 24px;
}

.card-footer {
    padding: 16px 24px;
    background-color: var(--surface-neutral);
    border-top: 1px solid var(--border-subdued);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.card-title {
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.card-subtitle {
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-subdued);
}

.card-text {
    margin-bottom: 16px;
    color: var(--text-subdued);
    font-size: 14px;
    line-height: 1.5;
}

/* Polaris User Avatar */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--interactive);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: var(--font-semibold);
    margin-right: 8px;
    text-transform: uppercase;
}

.dropdown-toggle:hover {
    background-color: var(--surface-hovered);
}

.dropdown-toggle::after {
    color: var(--text-subdued);
}

/* Polaris Settings Page Alignment */
.card-body .form-check {
    margin-left: 0;
    padding-left: 0;
}

.card-body .mb-3 {
    margin-left: 0;
}

.card-body .form-check .form-check-input {
    margin-left: 0;
}

.card-body .form-check .form-check-label {
    margin-left: 0.5rem;
}

/* ========== ALERTS ========== */

.alert {
    position: relative;
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius);
    border-left: 4px solid;
}

.alert-success {
    color: #065f46;
    background-color: var(--success-light);
    border-left-color: var(--success);
}

.alert-danger {
    color: #991b1b;
    background-color: var(--error-light);
    border-left-color: var(--error);
}

.alert-warning {
    color: #92400e;
    background-color: var(--warning-light);
    border-left-color: var(--warning);
}

.alert-info {
    color: #1e40af;
    background-color: var(--info-light);
    border-left-color: var(--info);
}

.alert-dismissible {
    padding-right: var(--space-12);
}

.btn-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 2;
    padding: 0;
    width: var(--space-6);
    height: var(--space-6);
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    opacity: 0.5;
    cursor: pointer;
}

.btn-close:hover {
    opacity: 0.75;
}

/* ========== BADGES ========== */

.badge {
    display: inline-block;
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    line-height: 1;
    color: var(--surface);
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--radius-sm);
}

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

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

.bg-danger {
    background-color: var(--error) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

/* ========== POSITION BADGES ========== */

.position-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    min-width: 50px;
    text-align: center;
    color: white;
    box-shadow: var(--shadow-sm);
}

.position-gold,
.position-silver,
.position-bronze,
.position-excellent {
    background: var(--position-excellent);
}

.position-good {
    background: var(--position-good);
}

.position-poor {
    background: var(--position-poor);
}

.position-not-found {
    background: var(--position-not-found);
}

/* ========== TABLES ========== */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    margin-bottom: 0;
    color: var(--text-primary);
    vertical-align: top;
    border-color: var(--border);
}

.table th,
.table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.table thead th {
    vertical-align: bottom;
    background-color: var(--surface-secondary);
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
}

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

.compact-table th,
.compact-table td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
}

.clickable-row {
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.clickable-row:hover {
    background-color: var(--surface-tertiary) !important;
}

/* Modern table container */
.modern-table-container {
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    background: transparent;
}

.modern-table thead tr {
    background: var(--surface-secondary);
    border-bottom: 2px solid var(--border);
}

.modern-table thead th {
    padding: var(--space-5) var(--space-6);
    text-align: left;
    font-weight: var(--font-semibold);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
}

.modern-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background-color var(--transition-fast);
}

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

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

.modern-table tbody td {
    padding: var(--space-5) var(--space-6);
    vertical-align: middle;
    border: none;
}

/* ========== NAVIGATION ========== */

.navbar {
    background-color: var(--surface) !important;
    border-bottom: 1px solid var(--border-subdued) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
    font-weight: var(--font-semibold);
    font-size: var(--text-lg);
    color: #FFFFFF !important;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: var(--font-semibold);
    transition: all 150ms ease-in-out;
    color: var(--text-subdued) !important;
    text-decoration: none !important;
    margin: 0 4px;
}

.nav-link:hover {
    background-color: var(--surface-hovered);
    color: var(--text) !important;
}

/* Polaris Navbar overrides */
.navbar .nav-link,
.navbar .navbar-nav .nav-link {
    color: var(--text-subdued) !important;
}

.navbar .dropdown-toggle {
    color: var(--text) !important;
    font-weight: var(--font-medium);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.nav-link.active {
    background-color: var(--surface-selected);
    color: var(--interactive) !important;
    font-weight: var(--font-semibold);
}

.dropdown-menu {
    border: 1px solid var(--border-subdued);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    background-color: var(--surface);
    overflow: hidden;
    padding: 4px 0;
    margin-top: 4px;
    min-width: 160px;
}

.dropdown-item {
    padding: 6px 12px;
    color: var(--text);
    font-size: var(--text-body);
    font-weight: var(--font-medium);
    transition: all 150ms ease-in-out;
    text-decoration: none;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--surface-hovered);
    color: var(--text);
    text-decoration: none;
}

.dropdown-divider {
    margin: 4px 0;
    border-top: 1px solid var(--border-subdued);
}

/* ========== MODALS ========== */

.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    background-color: var(--surface);
}

.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

.modal-title {
    margin-bottom: 0;
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
}

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

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--border);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

/* ========== UTILITIES ========== */

/* Spacing utilities */
.p-0 { padding: 0 !important; }
.p-1 { padding: var(--space-1) !important; }
.p-2 { padding: var(--space-2) !important; }
.p-3 { padding: var(--space-3) !important; }
.p-4 { padding: var(--space-4) !important; }
.p-5 { padding: var(--space-5) !important; }
.p-6 { padding: var(--space-6) !important; }

.m-0 { margin: 0 !important; }
.m-1 { margin: var(--space-1) !important; }
.m-2 { margin: var(--space-2) !important; }
.m-3 { margin: var(--space-3) !important; }
.m-4 { margin: var(--space-4) !important; }
.m-5 { margin: var(--space-5) !important; }
.m-6 { margin: var(--space-6) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--space-1) !important; }
.mb-2 { margin-bottom: var(--space-2) !important; }
.mb-3 { margin-bottom: var(--space-3) !important; }
.mb-4 { margin-bottom: var(--space-4) !important; }
.mb-5 { margin-bottom: var(--space-5) !important; }
.mb-6 { margin-bottom: var(--space-6) !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--space-1) !important; }
.mt-2 { margin-top: var(--space-2) !important; }
.mt-3 { margin-top: var(--space-3) !important; }
.mt-4 { margin-top: var(--space-4) !important; }
.mt-5 { margin-top: var(--space-5) !important; }
.mt-6 { margin-top: var(--space-6) !important; }

/* Text utilities */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.text-success { color: var(--success) !important; }
.text-danger { color: var(--error) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }

/* Display utilities */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }

/* Flex utilities */
.justify-content-start { justify-content: flex-start !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }

.align-items-start { align-items: flex-start !important; }
.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }

.flex-column { flex-direction: column !important; }
.flex-row { flex-direction: row !important; }

/* Gap utilities */
.gap-1 { gap: var(--space-1) !important; }
.gap-2 { gap: var(--space-2) !important; }
.gap-3 { gap: var(--space-3) !important; }
.gap-4 { gap: var(--space-4) !important; }

/* ========== ANIMATIONS ========== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.3s ease-out;
}

/* ========== MOBILE RESPONSIVE DESIGN ========== */

@media (max-width: 768px) {
    /* Base adjustments */
    body {
        font-size: var(--text-sm);
    }
    
    .container-fluid {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }
    
    /* Typography adjustments */
    h1 { font-size: var(--text-2xl); }
    h2 { font-size: var(--text-xl); }
    h3 { font-size: var(--text-lg); }
    .display-5 { font-size: var(--text-3xl); }
    
    /* Card adjustments */
    .card-body {
        padding: var(--space-4);
    }
    
    .card-header,
    .card-footer {
        padding: var(--space-4);
    }
    
    /* Button adjustments */
    .btn {
        padding: var(--space-3) var(--space-4);
        font-size: var(--text-base);
        min-height: 48px; /* Larger touch targets */
    }
    
    .btn-lg {
        padding: var(--space-4) var(--space-6);
        font-size: var(--text-lg);
        min-height: 52px;
    }
    
    .btn-sm {
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-sm);
        min-height: 40px;
    }
    
    /* Form adjustments */
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 48px;
    }
    
    /* Modal adjustments */
    .modal-dialog {
        margin: var(--space-4);
        max-width: calc(100vw - 2rem);
    }
    
    .modal-content {
        border-radius: var(--radius-md);
    }
    
    .modal-footer {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .modal-footer .btn {
        width: 100%;
        order: 2;
    }
    
    .modal-footer .btn:first-child {
        order: 1;
    }
    
    /* Table to card conversion */
    .modern-table-container {
        background: transparent;
        border: none;
        box-shadow: none;
    }
    
    .modern-table {
        display: none !important;
    }
    
    .mobile-cards {
        display: block !important;
    }
    
    .mobile-card {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin-bottom: var(--space-4);
        padding: var(--space-5);
        box-shadow: var(--shadow-sm);
    }
    
    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: var(--space-4);
    }
    
    .mobile-card-title {
        font-weight: var(--font-semibold);
        font-size: var(--text-base);
        color: var(--text-primary);
        margin-bottom: var(--space-1);
        flex: 1;
        margin-right: var(--space-3);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .mobile-card-actions {
        display: flex;
        align-items: center;
        gap: var(--space-2);
    }
    
    .mobile-card-body {
        display: flex;
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .mobile-field {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: var(--space-2);
    }
    
    .mobile-field-label {
        font-size: var(--text-xs);
        font-weight: var(--font-semibold);
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        min-width: 100px;
        flex-shrink: 0;
    }
    
    .mobile-field-value {
        font-size: var(--text-sm);
        display: flex;
        align-items: center;
    }
    
    /* Header adjustments for mobile */
    .d-flex.justify-content-between.align-items-center {
        flex-direction: column;
        align-items: center;
        gap: var(--space-4);
        text-align: center;
    }
    
    .d-flex.justify-content-between.align-items-center h1 {
        font-size: var(--text-xl);
        margin-bottom: 0;
    }
    
    .d-flex.justify-content-between.align-items-center .btn {
        width: 100%;
        font-size: var(--text-base);
        padding: var(--space-4) var(--space-5);
    }
    
    /* Legacy mobile-header class */
    .mobile-header {
        text-align: center;
        margin-bottom: var(--space-6);
    }
    
    .mobile-header h1 {
        font-size: var(--text-xl);
        margin-bottom: var(--space-4);
        line-height: 1.2;
    }
    
    .mobile-header .btn {
        width: 100%;
        font-size: var(--text-base);
        padding: var(--space-4) var(--space-5);
    }
    
    /* Navigation adjustments */
    .navbar-toggler {
        border: none;
        padding: var(--space-2);
        background-color: transparent;
        min-height: 48px;
        min-width: 48px;
    }
    
    .navbar-toggler:focus {
        box-shadow: none;
    }
}

/* Hide mobile cards on desktop */
@media (min-width: 769px) {
    .mobile-cards {
        display: none !important;
    }
}

/* Note: Dark mode support removed for better readability and contrast */

/* ========== LEGACY COMPATIBILITY ========== */

/* Legacy button classes for backward compatibility */
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active,
.btn-outline-primary.active {
    background: var(--primary) !important;
    color: #FFFFFF !important; /* Force white text for all states */
    border-color: var(--primary) !important;
    box-shadow: none !important;
}

/* Legacy table classes */
.table-light {
    background-color: var(--surface-secondary);
}

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

/* Legacy alert classes */
.alert-dismissible .btn-close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    padding: 1.25rem 1rem;
}

/* Legacy form classes */
.form-control-lg {
    padding: var(--space-4) var(--space-5);
    font-size: var(--text-lg);
    border-radius: var(--radius);
    min-height: 52px;
}

.form-control-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
    min-height: 36px;
}

/* Legacy position classes for history page compatibility */
.position-change-up { color: var(--success) !important; font-weight: var(--font-semibold); }
.position-change-down { color: var(--error) !important; font-weight: var(--font-semibold); }
.position-change-same { color: var(--text-muted) !important; }

/* Legacy chart and history specific styles */
.chart-container {
    position: relative;
    height: 300px;
    margin: var(--space-4) 0;
}

.chart-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    background-color: var(--surface-secondary);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-style: italic;
}

.filter-row {
    display: flex;
    gap: var(--space-4);
    align-items: end;
}

@media (max-width: 768px) {
    .filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
    
    .chart-container {
        height: 250px;
    }
}

/* Password requirement styles for auth forms */
.requirement {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.requirement.valid {
    color: var(--success);
}

.requirement .req-icon {
    display: inline-block;
    width: 12px;
    font-weight: var(--font-bold);
    margin-right: var(--space-1);
}

.requirement.valid .req-icon {
    color: var(--success);
}

/* Delete button styles */
.delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius);
    background: var(--surface-secondary);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.delete-btn:hover {
    background: var(--error-light);
    color: var(--error);
    transform: scale(1.05);
}

.delete-btn i {
    width: 16px;
    height: 16px;
}

@media (max-width: 768px) {
    .delete-btn {
        width: 44px;
        height: 44px;
        border-radius: var(--radius);
    }
    
    .delete-btn i {
        width: 18px;
        height: 18px;
    }
}

/* Feather icon utilities */
.feather-sm { width: 14px; height: 14px; }
.feather-xs { width: 12px; height: 12px; }

/* Focus states for accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.1);
}

/* Ensure all interactive elements have proper focus states */
a:focus,
button:focus,
[tabindex]:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Remove outline for mouse users, keep for keyboard users */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
}