/* Polymarket MCP Dashboard - Dark Mode Styling */

/* ============================================================================
   CSS Variables - Dark Theme
   ============================================================================ */
:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f29;
    --bg-tertiary: #252d3a;
    --bg-hover: #2d3748;

    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --border-color: #374151;
    --border-hover: #4b5563;

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #6b7280;
    --secondary-hover: #4b5563;

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

    --transition: all 0.2s ease;
}

/* ============================================================================
   Base Styles
   ============================================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ============================================================================
   Navigation
   ============================================================================ */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.nav-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 0.5rem;
}

.nav-menu a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-menu a:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-menu a.active {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

/* ============================================================================
   Main Content
   ============================================================================ */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

.section {
    margin-bottom: 2rem;
}

.section h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* ============================================================================
   Cards
   ============================================================================ */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

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

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

.card-body {
    padding: 1.5rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* ============================================================================
   Stats
   ============================================================================ */
.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
}

/* ============================================================================
   Status Badge
   ============================================================================ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
}

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

.status-online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-offline {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

/* ============================================================================
   Buttons
   ============================================================================ */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
}

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

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.button-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ============================================================================
   Forms
   ============================================================================ */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
}

.form-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    outline: none;
    -webkit-appearance: none;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.form-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.range-value {
    display: inline-block;
    margin-left: 1rem;
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

.help-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

/* ============================================================================
   Search & Filters
   ============================================================================ */
.search-container {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ============================================================================
   Tables
   ============================================================================ */
.table-responsive {
    overflow-x: auto;
}

.markets-table {
    width: 100%;
    border-collapse: collapse;
}

.markets-table thead {
    background: var(--bg-tertiary);
}

.markets-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

.markets-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.markets-table tbody tr:hover {
    background: var(--bg-hover);
}

.market-question {
    font-weight: 500;
    max-width: 400px;
}

.price-yes {
    color: var(--success);
    font-weight: 600;
}

.price-no {
    color: var(--error);
    font-weight: 600;
}

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

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* ============================================================================
   Market List
   ============================================================================ */
.market-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.market-item {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.market-item:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.market-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.market-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================================================
   Modal
   ============================================================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 2rem;
    height: 2rem;
}

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

.modal-body {
    padding: 1.5rem;
}

/* ============================================================================
   Info Grid
   ============================================================================ */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.info-item {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.detail-item {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* ============================================================================
   Loading States
   ============================================================================ */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

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

/* ============================================================================
   Notifications
   ============================================================================ */
.notification {
    position: fixed;
    top: 5rem;
    right: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification.success {
    border-left: 4px solid var(--success);
}

.notification.error {
    border-left: 4px solid var(--error);
}

.notification.warning {
    border-left: 4px solid var(--warning);
}

.notification.info {
    border-left: 4px solid var(--info);
}

/* ============================================================================
   Utility Classes
   ============================================================================ */
.mono {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.875rem;
}

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

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

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

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

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

/* ============================================================================
   Rate Limit Display
   ============================================================================ */
.rate-limit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.rate-limit-item {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.progress-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    margin: 0.75rem 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success);
    transition: width 0.3s ease;
}

.rate-limit-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================================================
   Log Container
   ============================================================================ */
.log-container {
    max-height: 400px;
    overflow-y: auto;
}

.log-entry {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
}

.log-time {
    color: var(--text-muted);
    font-size: 0.875rem;
    flex-shrink: 0;
}

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

/* ============================================================================
   Footer
   ============================================================================ */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: 3rem;
}

.footer p {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */
@media (max-width: 768px) {
    .navbar .container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        width: 100%;
        justify-content: center;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .search-container {
        flex-direction: column;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .markets-table {
        font-size: 0.875rem;
    }

    .markets-table th,
    .markets-table td {
        padding: 0.5rem;
    }
}

/* ============================================================================
   Analysis Styles
   ============================================================================ */
.market-analysis {
    padding: 1rem 0;
}

.analysis-section {
    margin-bottom: 1.5rem;
}

.analysis-section h4 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.analysis-recommendation {
    padding: 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    text-align: center;
}

.analysis-recommendation.buy {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.analysis-recommendation.sell {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.analysis-recommendation.hold {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.confidence-bar {
    position: relative;
    height: 30px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--error), var(--warning), var(--success));
    transition: width 0.5s ease;
}

.confidence-bar span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    color: var(--text-primary);
}
