/**
 * TOUCHSCREEN-OPTIMIZED STYLES
 * Designed for Tesla Model 3 / Tablet displays
 * No scrolling - everything fits in viewport
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --bg: #0a0a0f;
    --bg-secondary: #141420;
    --bg-tertiary: #1e1e2e;
    --text: #ffffff;
    --text-secondary: #a0a0b8;
    --accent: #f093fb;
    --success: #10b981;
    --radius: 16px;
}

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    touch-action: manipulation;
    user-select: none;
}

/* Tesla Mode Toggle */
.tesla-toggle-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.tesla-toggle {
    display: block;
    position: relative;
    width: 80px;
    height: 40px;
    cursor: pointer;
}

.tesla-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border-radius: 40px;
    transition: all 0.3s;
    border: 2px solid var(--text-secondary);
    display: flex;
    align-items: center;
    padding: 4px;
}

.toggle-icon {
    position: absolute;
    font-size: 20px;
    transition: all 0.3s;
    left: 8px;
    filter: grayscale(1) opacity(0.5);
}

.tesla-toggle input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-color: var(--primary);
}

.tesla-toggle input:checked + .toggle-slider .toggle-icon {
    left: calc(100% - 36px);
    filter: grayscale(0) opacity(1);
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    flex-direction: column;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active {
    display: flex;
    opacity: 1;
    transform: translateX(0);
}

/* Home Screen - Service Grid */
#homeScreen {
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.service-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    max-width: 900px;
    width: 100%;
}

.service-tile {
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    transition: all 0.3s;
    padding: 20px;
}

.service-tile:active {
    transform: scale(0.95);
}

.service-tile:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(102, 126, 234, 0.3);
}

.service-icon {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.service-icon svg {
    width: 48px;
    height: 48px;
}

.service-label {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

/* Screen Header */
.screen-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 30px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
    flex-shrink: 0;
}

.back-btn {
    background: var(--bg-tertiary);
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.back-btn:active {
    transform: scale(0.95);
}

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

.screen-header h2 {
    font-size: 28px;
    font-weight: 700;
}

/* Search Container */
.search-container {
    padding: 20px 30px;
    background: var(--bg-secondary);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.search-container input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    padding: 16px 20px;
    border-radius: 12px;
    color: var(--text);
    font-size: 16px;
    transition: all 0.2s;
}

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

.search-container button {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.search-container button:active {
    transform: scale(0.9);
}

.search-container button:hover {
    background: var(--primary-dark);
}

/* Video Results */
.video-results {
    flex: 1;
    overflow-y: auto;
    padding: 20px 30px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    align-content: start;
}

.video-results::-webkit-scrollbar {
    width: 8px;
}

.video-results::-webkit-scrollbar-track {
    background: var(--bg);
}

.video-results::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.video-results::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.video-item {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
}

.video-item:active {
    transform: scale(0.98);
}

.video-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.video-thumb {
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-size: cover;
    background-position: center;
}

.play-overlay {
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    padding-left: 4px;
}

.video-info {
    padding: 16px;
}

.video-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-meta {
    font-size: 14px;
    color: var(--text-secondary);
}

/* No Results State */
.no-results {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px;
    color: var(--text-secondary);
}

.no-results svg {
    opacity: 0.3;
}

.no-results p {
    font-size: 18px;
}

/* Loading State */
.loading {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

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

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

/* Responsive - Tesla Model 3 Screen (1200x1920 landscape) */
@media (min-width: 1200px) and (max-width: 1920px) {
    .service-grid {
        max-width: 1000px;
        gap: 40px;
    }

    .service-icon {
        width: 100px;
        height: 100px;
    }

    .service-icon svg {
        width: 60px;
        height: 60px;
    }

    .service-label {
        font-size: 20px;
    }
}

/* Tablet Portrait */
@media (max-width: 768px) {
    .service-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .video-results {
        grid-template-columns: 1fr;
    }

    .tesla-toggle-container {
        top: 12px;
        right: 12px;
    }

    .tesla-toggle {
        width: 70px;
        height: 36px;
    }

    .toggle-icon {
        font-size: 18px;
    }
}

/* Small devices */
@media (max-width: 480px) {
    .service-grid {
        gap: 16px;
        padding: 20px;
    }

    .service-icon {
        width: 60px;
        height: 60px;
    }

    .service-icon svg {
        width: 36px;
        height: 36px;
    }

    .service-label {
        font-size: 14px;
    }

    .screen-header h2 {
        font-size: 20px;
    }
}
