/* 
 * Dotty API Documentation CSS Framework
 * Modern, interactive API documentation styling
 * Version: 1.0.0
 */

/* ===== CSS VARIABLES ===== */
:root {
    /* API Documentation Theme Colors - Easy to customize */
    --api-primary-color: #667eea;
    --api-primary-dark: #5a67d8;
    --api-secondary-color: #764ba2;
    --api-primary-gradient: linear-gradient(135deg, var(--api-primary-color) 0%, var(--api-secondary-color) 100%);
    
    /* Legacy support - will be deprecated */
    --primary-gradient: var(--api-primary-gradient);
    --primary-color: var(--api-primary-color);
    --primary-dark: var(--api-primary-dark);
    --secondary-color: var(--api-secondary-color);
    
    /* Status Colors */
    --success-color: #28a745;
    --success-bg: #d4edda;
    --success-text: #155724;
    --danger-color: #dc3545;
    --danger-bg: #f8d7da;
    --danger-text: #721c24;
    --warning-color: #ffc107;
    --warning-bg: #fff3cd;
    --warning-text: #856404;
    --info-color: #17a2b8;
    --info-bg: #d1ecf1;
    --info-text: #0c5460;
    
    /* Neutral Colors */
    --text-primary: #2c3e50;
    --text-secondary: #34495e;
    --text-muted: #6c757d;
    --text-light: #f8f9fa;
    --text-contrast: #ffffff; /* High contrast text for dark backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-dark: #2d3748;
    --border-color: #dee2e6;
    --border-light: #e9ecef;
    
    /* Dark mode colors */
    --dark-text-primary: #e2e8f0;
    --dark-text-secondary: #a0aec0;
    --dark-text-muted: #718096;
    --dark-bg-primary: #2d3748;
    --dark-bg-secondary: #1a202c;
    --dark-border-color: #4a5568;
    --dark-border-light: #2d3748;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: 'Monaco', 'Menlo', 'Courier New', monospace;
    --font-size-base: 1rem;
    --font-size-sm: 0.875rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --line-height-base: 1.6;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;
    
    /* Border Radius */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* ===== COMPACT HEADER COMPONENT ===== */
.api-header {
    background: var(--api-primary-gradient);
    color: var(--text-contrast);
    padding: var(--spacing-lg) 0; /* Reduced from var(--spacing-xxl) */
    text-align: center;
    margin-bottom: var(--spacing-lg); /* Reduced from var(--spacing-xl) */
    position: relative;
    overflow: hidden;
}

.api-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
}

.api-header * {
    position: relative;
    z-index: 1;
    color: var(--text-contrast) !important;
}

.api-header h1 {
    font-size: 1.75rem; /* Reduced from 3rem */
    margin-bottom: var(--spacing-xs); /* Reduced from var(--spacing-sm) */
    font-weight: 600; /* Reduced from 700 */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); /* Reduced shadow */
    color: var(--text-contrast) !important;
}

.api-header p {
    font-size: var(--font-size-base); /* Reduced from var(--font-size-xl) */
    opacity: 0.9; /* Slightly reduced from 0.95 */
    max-width: 600px;
    margin: 0 auto var(--spacing-xs) auto; /* Added small bottom margin */
    color: var(--text-contrast) !important;
}

.api-header .api-version {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-contrast) !important;
    padding: var(--spacing-xs) var(--spacing-sm); /* Kept same for visibility */
    border-radius: var(--border-radius-lg);
    font-size: 0.75rem; /* Slightly smaller */
    margin-top: var(--spacing-xs); /* Reduced from var(--spacing-md) */
}

/* Optional: Even more compact version */
.api-header-minimal {
    background: var(--api-primary-gradient);
    color: var(--text-contrast);
    padding: var(--spacing-md) 0; /* Even smaller padding */
    text-align: center;
    margin-bottom: var(--spacing-md);
    position: relative;
    overflow: hidden;
}

.api-header-minimal h1 {
    font-size: 1.5rem;
    margin-bottom: 0;
    font-weight: 600;
    color: var(--text-contrast) !important;
}

.api-header-minimal p {
    font-size: var(--font-size-sm);
    opacity: 0.85;
    margin: var(--spacing-xs) auto 0 auto;
    color: var(--text-contrast) !important;
}

.api-header-minimal .api-version {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-contrast) !important;
    padding: 2px var(--spacing-xs);
    border-radius: var(--border-radius-sm);
    font-size: 0.7rem;
    margin-top: var(--spacing-xs);
}

/* Responsive adjustments for compact header */
@media (max-width: 768px) {
    .api-header h1 {
        font-size: 1.5rem; /* Further reduced for mobile */
    }
    
    .api-header p {
        font-size: var(--font-size-sm);
    }
    
    .api-header-minimal h1 {
        font-size: 1.25rem;
    }
    
    .api-header-minimal p {
        font-size: 0.8rem;
    }
}

/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    line-height: var(--line-height-base);
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    font-size: var(--font-size-base);
}

/* ===== LAYOUT COMPONENTS ===== */
.api-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

.api-container-wide {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

.api-container-narrow {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* ===== HEADER COMPONENT ===== */
.api-header {
    background: var(--api-primary-gradient);
    color: var(--text-contrast);
    padding: var(--spacing-xxl) 0;
    text-align: center;
    margin-bottom: var(--spacing-xl);
    position: relative;
    overflow: hidden;
}

.api-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
}

.api-header * {
    position: relative;
    z-index: 1;
    color: var(--text-contrast) !important;
}

.api-header h1 {
    font-size: 3rem;
    margin-bottom: var(--spacing-sm);
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    color: var(--text-contrast) !important;
}

.api-header p {
    font-size: var(--font-size-xl);
    opacity: 0.95;
    max-width: 600px;
    margin: 0 auto;
    color: var(--text-contrast) !important;
}

.api-header .api-version {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-contrast) !important;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--border-radius-lg);
    font-size: var(--font-size-sm);
    margin-top: var(--spacing-md);
}

/* API Header with dotty integration */
.api-docs-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.api-docs-content {
    flex: 1;
}

/* ===== CONTENT COMPONENTS ===== */
.api-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.api-content-flat {
    background: var(--bg-primary);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

/* ===== TYPOGRAPHY ===== */
.api-content h2 {
    color: var(--text-primary);
    font-size: 2rem;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-sm);
    border-bottom: 3px solid var(--primary-color);
    position: relative;
}

.api-content h2::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 60px;
    height: 3px;
    background: var(--secondary-color);
    border-radius: 2px;
}

.api-content h3 {
    color: var(--text-secondary);
    font-size: 1.4rem;
    margin: var(--spacing-xl) 0 var(--spacing-md) 0;
}

.api-content h4 {
    color: var(--text-secondary);
    font-size: var(--font-size-lg);
    margin: var(--spacing-lg) 0 var(--spacing-sm) 0;
}

.api-content p {
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

.api-content ul, .api-content ol {
    margin-bottom: var(--spacing-md);
    padding-left: var(--spacing-lg);
}

.api-content li {
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
}

/* ===== ENDPOINT COMPONENTS ===== */
.api-endpoint {
    background: var(--bg-secondary);
    border-left: 4px solid var(--primary-color);
    padding: var(--spacing-lg);
    margin: var(--spacing-lg) 0;
    border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
    position: relative;
    transition: var(--transition-base);
}

.api-endpoint:hover {
    box-shadow: var(--shadow-sm);
    transform: translateX(2px);
}

.api-endpoint-header {
    display: flex;
    align-items: center;
    margin-bottom: var(--spacing-sm);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.api-method {
    display: inline-block;
    color: white;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-weight: bold;
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    min-width: 60px;
    text-align: center;
}

.api-method-get { background: var(--info-color); }
.api-method-post { background: var(--success-color); }
.api-method-put { background: var(--warning-color); color: var(--text-primary); }
.api-method-patch { background: var(--api-secondary-color); }
.api-method-delete { background: var(--danger-color); }

.api-url {
    font-family: var(--font-mono);
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    font-weight: 500;
    flex: 1;
}

.api-endpoint-description {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin-top: var(--spacing-xs);
}

/* ===== CODE COMPONENTS ===== */
.api-code {
    background: var(--bg-dark);
    color: #e2e8f0;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-md);
    overflow-x: auto;
    margin: var(--spacing-md) 0;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    line-height: 1.4;
    position: relative;
}

.api-code::before {
    content: attr(data-language);
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.1);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    text-transform: uppercase;
    opacity: 0.7;
}

.api-code-inline {
    background: #f1f3f4;
    padding: 2px 6px;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-mono);
    color: #d63384;
    font-size: 0.9em;
}

/* ===== TABLE COMPONENTS ===== */
.api-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-lg) 0;
    background: var(--bg-primary);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.api-table th,
.api-table td {
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.api-table th {
    background-color: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.api-table tr:hover {
    background-color: var(--bg-secondary);
}

.api-table tr:last-child td {
    border-bottom: none;
}

/* ===== BADGE COMPONENTS ===== */
.api-badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-lg);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.api-badge-danger {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

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

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

.api-badge-required {
    background: var(--danger-color);
    color: white;
}

.api-badge-optional {
    background: var(--text-muted);
    color: white;
}

/* ===== INTERACTIVE COMPONENTS ===== */
.api-try-it {
    background: var(--api-primary-gradient);
    color: var(--text-contrast);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-md);
    margin: var(--spacing-lg) 0;
    position: relative;
    overflow: hidden;
}

.api-try-it::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="2" fill="rgba(255,255,255,0.1)"/></svg>');
    opacity: 0.3;
}

.api-try-it * {
    position: relative;
    z-index: 1;
}

.api-try-it h3,
.api-try-it h4 {
    color: var(--text-contrast) !important;
    margin-bottom: var(--spacing-md);
}

.api-try-it p {
    color: var(--text-contrast) !important;
}

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

.api-form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    color: var(--text-contrast) !important;
}

.api-form-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-base);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-contrast);
    transition: var(--transition-base);
}

.api-form-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.api-form-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

/* Select styling for interactive components */
.api-try-it select.api-form-input {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-contrast);
}

.api-try-it select.api-form-input option {
    background: var(--api-primary-color);
    color: var(--text-contrast);
}

.api-btn {
    background: var(--success-color);
    color: white;
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: var(--font-size-base);
    font-weight: 500;
    transition: var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.api-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.api-btn:active {
    transform: translateY(0);
}

.api-btn-primary {
    background: var(--primary-color);
}

.api-btn-primary:hover {
    background: var(--primary-dark);
}

.api-btn-danger {
    background: var(--danger-color);
}

.api-btn-danger:hover {
    background: #c82333;
}

.api-result {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-height: 60px;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
}

/* ===== NAVIGATION COMPONENTS ===== */
.api-toc {
    background: var(--bg-secondary);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-md);
    margin-bottom: var(--spacing-xl);
    border: 1px solid var(--border-light);
}

.api-toc h3 {
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.api-toc ul {
    list-style: none;
    padding: 0;
}

.api-toc li {
    margin: var(--spacing-sm) 0;
}

.api-toc a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-base);
    display: block;
    padding: var(--spacing-xs) 0;
}

.api-toc a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
    transform: translateX(4px);
}

/* ===== STATUS INDICATORS ===== */
.api-status {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.api-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.api-status-success .api-status-indicator {
    background: var(--success-color);
}

.api-status-error .api-status-indicator {
    background: var(--danger-color);
}

.api-status-warning .api-status-indicator {
    background: var(--warning-color);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .api-container,
    .api-container-wide,
    .api-container-narrow {
        padding: var(--spacing-md);
    }
    
    .api-header h1 {
        font-size: 2rem;
    }
    
    .api-header p {
        font-size: var(--font-size-base);
    }
    
    .api-content {
        padding: var(--spacing-lg);
    }
    
    .api-endpoint-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .api-table {
        font-size: var(--font-size-sm);
    }
    
    .api-table th,
    .api-table td {
        padding: var(--spacing-sm);
    }
}

/* ===== UTILITY CLASSES ===== */
.api-text-center { text-align: center; }
.api-text-left { text-align: left; }
.api-text-right { text-align: right; }

.api-mb-sm { margin-bottom: var(--spacing-sm); }
.api-mb-md { margin-bottom: var(--spacing-md); }
.api-mb-lg { margin-bottom: var(--spacing-lg); }
.api-mb-xl { margin-bottom: var(--spacing-xl); }

.api-mt-sm { margin-top: var(--spacing-sm); }
.api-mt-md { margin-top: var(--spacing-md); }
.api-mt-lg { margin-top: var(--spacing-lg); }
.api-mt-xl { margin-top: var(--spacing-xl); }

.api-p-sm { padding: var(--spacing-sm); }
.api-p-md { padding: var(--spacing-md); }
.api-p-lg { padding: var(--spacing-lg); }
.api-p-xl { padding: var(--spacing-xl); }

.api-text-muted { color: var(--text-muted); }
.api-text-primary { color: var(--primary-color); }
.api-text-success { color: var(--success-color); }
.api-text-danger { color: var(--danger-color); }
.api-text-warning { color: var(--warning-color); }

/* ===== ANIMATIONS ===== */
@keyframes api-fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes api-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.api-fade-in {
    animation: api-fade-in 0.6s ease-out;
}

.api-pulse {
    animation: api-pulse 2s infinite;
}

/* ===== DARK MODE SUPPORT ===== */
body.dark-mode {
    --text-primary: var(--dark-text-primary);
    --text-secondary: var(--dark-text-secondary);
    --text-muted: var(--dark-text-muted);
    --bg-primary: var(--dark-bg-primary);
    --bg-secondary: var(--dark-bg-secondary);
    --border-color: var(--dark-border-color);
    --border-light: var(--dark-border-light);
    
    background-color: var(--bg-secondary);
}

body.dark-mode .api-code-inline {
    background: #4a5568;
    color: #f687b3;
}

body.dark-mode .api-header {
    /* Gradient remains the same but text contrast is ensured */
    color: var(--text-contrast);
}

body.dark-mode .api-try-it {
    /* Gradient backgrounds maintain their vibrant colors in dark mode */
    color: var(--text-contrast);
}

@media (prefers-color-scheme: dark) {
    body:not(.light-mode) {
        --text-primary: var(--dark-text-primary);
        --text-secondary: var(--dark-text-secondary);
        --text-muted: var(--dark-text-muted);
        --bg-primary: var(--dark-bg-primary);
        --bg-secondary: var(--dark-bg-secondary);
        --border-color: var(--dark-border-color);
        --border-light: var(--dark-border-light);
        
        background-color: var(--bg-secondary);
    }
    
    body:not(.light-mode) .api-code-inline {
        background: #4a5568;
        color: #f687b3;
    }
}

/* ===== API THEMING UTILITIES ===== */
/* Easy theming classes for different APIs */
.api-theme-purple {
    --api-primary-color: #6f42c1;
    --api-secondary-color: #9c27b0;
    --api-primary-gradient: linear-gradient(135deg, #6f42c1 0%, #9c27b0 100%);
}

.api-theme-blue {
    --api-primary-color: #007bff;
    --api-secondary-color: #0056b3;
    --api-primary-gradient: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
}

.api-theme-green {
    --api-primary-color: #28a745;
    --api-secondary-color: #20c997;
    --api-primary-gradient: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.api-theme-orange {
    --api-primary-color: #fd7e14;
    --api-secondary-color: #ffc107;
    --api-primary-gradient: linear-gradient(135deg, #fd7e14 0%, #ffc107 100%);
}

.api-theme-red {
    --api-primary-color: #dc3545;
    --api-secondary-color: #e83e8c;
    --api-primary-gradient: linear-gradient(135deg, #dc3545 0%, #e83e8c 100%);
}

.api-theme-teal {
    --api-primary-color: #20c997;
    --api-secondary-color: #17a2b8;
    --api-primary-gradient: linear-gradient(135deg, #20c997 0%, #17a2b8 100%);
}
