/**
 * Agent.ai Shared Styles
 *
 * Design system and component library for all agent.ai applications.
 * Based on the xgrader app's clean, modern design.
 *
 * Sections:
 * 1. CSS Custom Properties (Design Tokens)
 * 2. Base Styles
 * 3. Typography
 * 4. Layout Components
 * 5. Form Elements
 * 6. Buttons
 * 7. Cards & Panels
 * 8. Stats & Metrics
 * 9. Badges & Labels
 * 10. Messages & Alerts
 * 11. Loading States
 * 12. Utility Classes
 * 13. Animations
 */

/* ============================================
   1. CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   ============================================ */

:root {
    /* Brand Colors */
    --color-brand-blue: #3182ce;
    --color-brand-blue-dark: #2563eb;
    --color-brand-blue-light: #4299e1;

    /* Background Colors */
    --color-bg-page: #f7f9fc;
    --color-bg-white: #ffffff;
    --color-bg-gray-50: #f7fafc;
    --color-bg-gray-100: #edf2f7;
    --color-bg-gray-200: #e2e8f0;

    /* Text Colors */
    --color-text-primary: #1a202c;
    --color-text-secondary: #2d3748;
    --color-text-tertiary: #4a5568;
    --color-text-muted: #718096;
    --color-text-subtle: #a0aec0;

    /* Border Colors */
    --color-border-default: #e2e8f0;
    --color-border-hover: #cbd5e0;
    --color-border-focus: #3182ce;

    /* State Colors */
    --color-success: #48bb78;
    --color-success-dark: #38a169;
    --color-success-bg: #f0fff4;
    --color-success-border: #c6f6d5;

    --color-warning: #ecc94b;
    --color-warning-dark: #d69e2e;
    --color-warning-bg: #fffff0;
    --color-warning-border: #fef2c0;

    --color-error: #e53e3e;
    --color-error-dark: #c53030;
    --color-error-light: #fc8181;
    --color-error-bg: #fff5f5;
    --color-error-border: #fed7d7;

    --color-info: #1DA1F2;
    --color-info-bg: #ebf8ff;
    --color-info-border: #bee3f8;

    /* Typography */
    --font-family-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --font-size-xs: 0.75rem;      /* 12px */
    --font-size-sm: 0.85rem;      /* 13.6px */
    --font-size-base: 0.95rem;    /* 15.2px */
    --font-size-md: 1rem;         /* 16px */
    --font-size-lg: 1.1rem;       /* 17.6px */
    --font-size-xl: 1.125rem;     /* 18px */
    --font-size-2xl: 1.5rem;      /* 24px */
    --font-size-3xl: 1.75rem;     /* 28px */

    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.6;

    /* Spacing Scale */
    --space-xs: 0.25rem;    /* 4px */
    --space-sm: 0.5rem;     /* 8px */
    --space-md: 0.75rem;    /* 12px */
    --space-lg: 1rem;       /* 16px */
    --space-xl: 1.5rem;     /* 24px */
    --space-2xl: 2rem;      /* 32px */
    --space-3xl: 3rem;      /* 48px */

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 50%;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(49, 130, 206, 0.4);
    --shadow-focus: 0 0 0 3px rgba(49, 130, 206, 0.1);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* ============================================
   2. BASE STYLES
   ============================================ */

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-primary);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--color-text-tertiary);
    margin: 0;
    padding: 0;
}

/* Page Wrapper */
.page-wrapper {
    background: var(--color-bg-page);
    min-height: 100vh;
}

/* Content Container */
.content-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-2xl);
}

.content-container-narrow {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-2xl);
}

.content-container-wide {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-2xl);
}

/* ============================================
   3. TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    line-height: var(--line-height-tight);
}

h1 {
    font-size: var(--font-size-3xl);
}

h2 {
    font-size: var(--font-size-2xl);
}

h3 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
}

h4 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

p {
    margin: 0 0 var(--space-lg) 0;
}

a {
    color: var(--color-brand-blue);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--color-brand-blue-dark);
}

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

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

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

/* ============================================
   4. LAYOUT COMPONENTS
   ============================================ */

/* Grid Layouts */
.grid {
    display: grid;
    gap: var(--space-lg);
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-lg);
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
}

/* Responsive Grid */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-4, .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .stats-grid,
    .meta-grid,
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Flex Utilities */
.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

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

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

/* ============================================
   5. FORM ELEMENTS
   ============================================ */

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

.form-label {
    display: block;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
}

.form-description {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-lg);
    line-height: var(--line-height-relaxed);
}

.input-field {
    width: 100%;
    padding: var(--space-lg) 1.25rem;
    font-size: var(--font-size-lg);
    font-family: var(--font-family-primary);
    border: 2px solid var(--color-border-default);
    border-radius: var(--radius-lg);
    background: var(--color-bg-white);
    color: var(--color-text-primary);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.input-field:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: var(--shadow-focus);
}

.input-field::placeholder {
    color: var(--color-text-subtle);
}

.input-field:disabled {
    background: var(--color-bg-gray-100);
    cursor: not-allowed;
    opacity: 0.6;
}

textarea.input-field {
    resize: vertical;
    min-height: 120px;
}

/* ============================================
   6. BUTTONS
   ============================================ */

.btn {
    display: inline-block;
    padding: var(--space-lg) var(--space-2xl);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-family-primary);
    text-align: center;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: transform var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Primary Button - Blue Gradient */
.btn-primary {
    color: var(--color-bg-white);
    background: linear-gradient(135deg, var(--color-brand-blue) 0%, var(--color-brand-blue-dark) 100%);
    padding: var(--space-lg) 3rem;
    font-size: var(--font-size-lg);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

/* Secondary Button - Green */
.btn-secondary {
    color: var(--color-bg-white);
    background: var(--color-success);
    padding: 0.5rem var(--space-lg);
    font-size: var(--font-size-base);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-success-dark);
}

/* Danger Button - Red */
.btn-danger {
    color: var(--color-bg-white);
    background: var(--color-error);
    padding: 0.5rem var(--space-lg);
    font-size: var(--font-size-base);
}

.btn-danger:hover:not(:disabled) {
    background: var(--color-error-dark);
}

/* Outline Button */
.btn-outline {
    color: var(--color-brand-blue);
    background: transparent;
    border: 2px solid var(--color-brand-blue);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-brand-blue);
    color: var(--color-bg-white);
}

/* Small Button */
.btn-sm {
    padding: 0.5rem var(--space-lg);
    font-size: var(--font-size-sm);
}

/* Large Button */
.btn-lg {
    padding: 1.25rem 3.5rem;
    font-size: 1.2rem;
}

/* ============================================
   7. CARDS & PANELS
   ============================================ */

.card {
    background: var(--color-bg-white);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-md);
}

.card-header {
    background: var(--color-bg-white);
    border-radius: var(--radius-xl);
    padding: var(--space-xl) var(--space-2xl);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-xl);
}

.card-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    margin: 0;
}

.card-body {
    padding: var(--space-xl);
}

.card-section {
    margin-bottom: var(--space-2xl);
}

.card-section:last-child {
    margin-bottom: 0;
}

/* ============================================
   8. STATS & METRICS
   ============================================ */

.stat-card {
    background: var(--color-bg-gray-50);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-default);
    text-align: center;
}

.stat-label {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

.stat-value {
    display: block;
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
}

.stat-change {
    display: block;
    font-size: var(--font-size-sm);
    margin-top: var(--space-sm);
}

.stat-change.positive {
    color: var(--color-success);
}

.stat-change.negative {
    color: var(--color-error);
}

/* ============================================
   9. BADGES & LABELS
   ============================================ */

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--color-bg-gray-50);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.badge:hover {
    background: var(--color-bg-gray-100);
    border-color: var(--color-border-hover);
}

.badge-verified {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.25rem 0.75rem;
    background: var(--color-brand-blue);
    color: var(--color-bg-white);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

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

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

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

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

/* ============================================
   10. MESSAGES & ALERTS
   ============================================ */

.message {
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
}

.message-success {
    background: var(--color-success-bg);
    border: 1px solid var(--color-success-border);
    color: var(--color-success-dark);
}

.message-warning {
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    color: var(--color-warning-dark);
}

.message-error,
.error-message {
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    color: var(--color-error-dark);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    margin-top: var(--space-lg);
}

.message-info {
    background: var(--color-info-bg);
    border: 1px solid var(--color-info-border);
    color: var(--color-info);
}

.error-container {
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
}

/* Analysis Items (Credits, Warnings, Ideas) */
.analysis-item {
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
    padding: var(--space-lg);
    background: var(--color-bg-gray-50);
    border-left: 3px solid var(--color-border-default);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
}

.analysis-item.credit {
    border-left-color: var(--color-success);
    background: var(--color-success-bg);
}

.analysis-item.warning {
    border-left-color: var(--color-error-light);
    background: var(--color-error-bg);
}

.analysis-item.idea {
    border-left-color: var(--color-warning);
    background: var(--color-warning-bg);
}

.analysis-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.analysis-text {
    color: var(--color-text-secondary);
    line-height: var(--line-height-relaxed);
    font-size: var(--font-size-base);
}

/* ============================================
   11. LOADING STATES
   ============================================ */

.loading-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    padding: 0.875rem var(--space-xl);
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    margin-top: var(--space-lg);
    border: 1px solid var(--color-border-default);
}

.loading-text {
    font-size: var(--font-size-base);
    color: var(--color-text-tertiary);
    font-weight: var(--font-weight-medium);
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(49, 130, 206, 0.1);
    border-top-color: var(--color-brand-blue);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

.loading-spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.loading-spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* ============================================
   12. UTILITY CLASSES
   ============================================ */

/* Spacing */
.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }

.p-0 { padding: 0; }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }
.p-2xl { padding: var(--space-2xl); }

/* Display */
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* Visibility */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Width */
.w-full { width: 100%; }
.w-auto { width: auto; }

/* Misc */
.cursor-pointer {
    cursor: pointer;
}

.no-wrap {
    white-space: nowrap;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   13. ANIMATIONS
   ============================================ */

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

.fade-in {
    animation: fadeIn var(--transition-base);
}

.slide-in {
    animation: slideIn var(--transition-base);
}

/* ============================================
   14. RESPONSIVE UTILITIES
   ============================================ */

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .content-container,
    .content-container-narrow,
    .content-container-wide {
        padding: var(--space-lg);
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}
