/* KSTK Radio - Mobile-First Responsive Styles */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
}

.logo-container {
    display: flex;
    align-items: center;
    padding: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    width: 60px;
    height: 30px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.logo-fallback {
    width: 60px;
    height: 30px;
    background: #667eea;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9rem;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3748;
    flex: 1;
    min-width: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.welcome-text {
    font-size: 0.9rem;
    color: #4a5568;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.logout-button {
    background: #e53e3e;
    border: none;
    border-radius: 6px;
    color: white;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-button:hover {
    background: #c53030;
    transform: translateY(-1px);
}

.logout-icon {
    font-size: 1rem;
    transform: rotate(45deg);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    padding: 1rem 0;
}

.login-form-wrapper {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    width: 100%;
    max-width: 400px;
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #2d3748;
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: 0.95rem;
    color: #718096;
    text-align: center;
    margin-bottom: 2rem;
}

/* Form Styles */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #4a5568;
}

.form-input {
    padding: 0.875rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input.error {
    border-color: #e53e3e;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.form-error {
    font-size: 0.8rem;
    color: #e53e3e;
    min-height: 1.2rem;
}

.login-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.login-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.login-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.button-text {
    display: inline-block;
    transition: opacity 0.2s;
}

.button-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s;
}

.login-button.loading .button-text {
    opacity: 0;
}

.login-button.loading .button-loader {
    opacity: 1;
}

.form-message {
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: center;
    margin-top: 0.5rem;
}

.form-message.success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.form-message.error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #feb2b2;
}

/* Radio Page Styles */
.radio-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 1rem;
}

.player-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.radio-player {
    width: 100%;
    max-width: 360px;
    height: 320px;
    border-radius: 8px;
    border: none;
}

/* Chat Section */
.chat-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 400px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.5rem;
    gap: 1rem;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.online-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #4a5568;
}

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

.status-dot.connecting {
    background: #ed8936;
}

.status-dot.disconnected {
    background: #e53e3e;
}

/* Users Section */
.users-section {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 1rem;
}

.users-toggle {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 0;
    cursor: pointer;
    font-size: 0.9rem;
    color: #4a5568;
    transition: color 0.2s;
}

.users-toggle:hover {
    color: #2d3748;
}

.toggle-arrow {
    transition: transform 0.2s;
}

.users-toggle.expanded .toggle-arrow {
    transform: rotate(180deg);
}

.users-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.users-list.expanded {
    max-height: 200px;
    padding-top: 0.5rem;
}

.users-loading {
    font-size: 0.8rem;
    color: #718096;
    text-align: center;
    padding: 1rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.85rem;
    color: #4a5568;
}

.user-status {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #48bb78;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    background: #fafafa;
    min-height: 200px;
    max-height: 300px;
}

.messages-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #718096;
    font-size: 0.9rem;
    padding: 2rem;
}

.message {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.message-author {
    font-weight: 600;
    color: #2d3748;
    font-size: 0.85rem;
}

.message-time {
    font-size: 0.75rem;
    color: #718096;
}

.message-content {
    color: #4a5568;
    font-size: 0.9rem;
    word-wrap: break-word;
    line-height: 1.4;
}

.message.system {
    font-style: italic;
    color: #718096;
    text-align: center;
}

.message.system .message-content {
    color: inherit;
}

/* Chat Input */
.chat-input-section {
    border-top: 1px solid #e2e8f0;
    padding-top: 1rem;
}

.chat-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.message-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    resize: none;
    transition: border-color 0.2s;
}

.message-input:focus {
    outline: none;
    border-color: #667eea;
}

.message-input:disabled {
    background: #f7fafc;
    color: #a0aec0;
}

.send-button {
    background: #667eea;
    border: none;
    border-radius: 6px;
    color: white;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
}

.send-button:hover:not(:disabled) {
    background: #5a67d8;
    transform: translateY(-1px);
}

.send-button:disabled {
    background: #a0aec0;
    cursor: not-allowed;
}

.char-counter {
    font-size: 0.75rem;
    color: #718096;
    text-align: right;
}

.char-counter.warning {
    color: #ed8936;
}

.char-counter.danger {
    color: #e53e3e;
}

.chat-error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #feb2b2;
    border-radius: 6px;
    padding: 0.5rem;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* Connection Status */
.connection-status {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    z-index: 1000;
    transform: translateY(-100px);
    opacity: 0;
    transition: all 0.3s;
}

.connection-status.show {
    transform: translateY(0);
    opacity: 1;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-text {
    font-size: 0.8rem;
    color: #4a5568;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-overlay.hidden {
    display: none;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 1rem 0;
}

.footer-text {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Responsive Design - Tablet */
@media (min-width: 768px) {
    .container {
        padding: 2rem;
        max-width: 1200px;
    }

    .main-content {
        gap: 2rem;
    }

    .radio-section,
    .chat-section {
        padding: 2rem;
    }

    .login-form-wrapper {
        padding: 3rem 2.5rem;
    }

    .site-title {
        font-size: 1.75rem;
    }

    .welcome-text {
        max-width: 200px;
    }

    .users-list.expanded {
        max-height: 150px;
    }

    .chat-messages {
        max-height: 400px;
    }
}

/* Responsive Design - Desktop */
@media (min-width: 1024px) {
    .main-content {
        flex-direction: row;
        align-items: flex-start;
    }

    .radio-section {
        flex: 0 0 400px;
    }

    .chat-section {
        flex: 1;
        min-height: 600px;
    }

    .users-toggle {
        display: none;
    }

    .users-list {
        max-height: none !important;
        padding-top: 0 !important;
        overflow: visible;
    }

    .chat-messages {
        max-height: 350px;
    }

    .logo {
        width: 80px;
        height: 40px;
    }

    .logo-fallback {
        width: 80px;
        height: 40px;
        font-size: 1.1rem;
    }
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo,
    .logo-fallback {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print Styles */
@media print {
    .loading-overlay,
    .connection-status,
    .logout-button,
    .chat-input-section {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .header,
    .radio-section,
    .chat-section {
        background: white;
        box-shadow: none;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles would go here if needed */
}

/* Focus styles for better accessibility */
button:focus,
input:focus,
.users-toggle:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .login-button:hover,
    .send-button:hover,
    .logout-button:hover {
        transform: none;
    }
    
    .login-button:active,
    .send-button:active,
    .logout-button:active {
        transform: scale(0.98);
    }
}