/**
 * Base Styles - Core styling foundation
 * Reset, typography, layout fundamentals
 */

/* CSS Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    line-height: 1.5;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #2d3748;
    background: linear-gradient(180deg, #4299e1 0%, #3182ce 50%, #2b77cb 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Layout Containers */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%);
    color: white;
    padding: 0.4rem 0;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 4px 12px rgba(37, 99, 235, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.test-link {
    color: white;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.test-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.app-title {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.app-main {
    flex: 1;
    max-width: 1200px;
    margin: 1rem auto;
    padding: 1rem;
    width: calc(100% - 2rem);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow:
        0 10px 20px rgba(0, 0, 0, 0.1),
        0 4px 8px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    transform: translateZ(0);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

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

.loading-screen h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.loading-screen p {
    font-size: 1rem;
    opacity: 0.8;
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #48bb78;
    animation: pulse 2s infinite;
}

.status-indicator.online {
    background-color: #48bb78;
}

.status-indicator.offline {
    background-color: #f56565;
}

.status-indicator.connecting {
    background-color: #ed8936;
}

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

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 0.5rem;
    color: #2d3748;
}

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

p {
    margin-bottom: 1rem;
    color: #4a5568;
}

/* Error Messages */
.error-message {
    background-color: #fed7d7;
    color: #9b2c2c;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #feb2b2;
    text-align: center;
}

.error-message h2 {
    color: #9b2c2c;
    margin-bottom: 0.5rem;
}

.error-message button {
    background-color: #e53e3e;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    cursor: pointer;
    margin-top: 1rem;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

.error-message button:hover {
    background-color: #c53030;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-main {
        padding: 1rem;
    }

    .header-content {
        padding: 0 1rem;
    }

    .app-title {
        font-size: 1.25rem;
    }

    .connection-status {
        font-size: 0.75rem;
    }

    .status-indicator {
        width: 6px;
        height: 6px;
    }

    .loading-screen h2 {
        font-size: 1.25rem;
    }

    .loading-screen p {
        font-size: 0.875rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner,
    .status-indicator {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background-color: white;
        color: black;
    }

    .app-header {
        background: #000;
        color: white;
    }
}