/* Supellex - Futuristic Voice Assistant */

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --accent: #06b6d4;
    --accent-glow: rgba(6, 182, 212, 0.4);
    --accent-bright: #22d3ee;
    --accent-secondary: #8b5cf6;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --border: rgba(6, 182, 212, 0.15);
    --glass: rgba(255, 255, 255, 0.03);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}

/* Background grid effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(6, 182, 212, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 100%, rgba(139, 92, 246, 0.06) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* App container */
.app {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 480px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0 24px;
    padding-top: env(safe-area-inset-top, 20px);
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* Header */
.header {
    text-align: center;
    padding: 24px 0 8px;
    flex-shrink: 0;
}

.header .logo {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--accent);
    opacity: 0.7;
}

.header .status {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.header .status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Middle area - main content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    min-height: 0;
}

/* Transcript / response area */
.response-area {
    width: 100%;
    text-align: center;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.response-text {
    font-size: 17px;
    line-height: 1.5;
    color: var(--text-primary);
    max-height: 200px;
    overflow-y: auto;
    padding: 0 8px;
    scroll-behavior: smooth;
}

.response-text::-webkit-scrollbar {
    width: 2px;
}

.response-text::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 1px;
}

.response-label {
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.response-text.transcript {
    color: var(--text-secondary);
    font-size: 14px;
    font-style: italic;
}

/* Waveform visualization */
.waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 48px;
    opacity: 0;
    transition: opacity 0.3s;
}

.waveform.active {
    opacity: 1;
}

.waveform .bar {
    width: 3px;
    height: 8px;
    background: var(--accent);
    border-radius: 2px;
    transition: height 0.1s ease;
}

/* Central button */
.btn-area {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Outer rings */
.btn-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--border);
    pointer-events: none;
    transition: all 0.5s ease;
}

.btn-ring-1 {
    width: 200px;
    height: 200px;
}

.btn-ring-2 {
    width: 240px;
    height: 240px;
    opacity: 0.5;
}

.btn-ring-3 {
    width: 280px;
    height: 280px;
    opacity: 0.2;
}

.recording .btn-ring {
    border-color: var(--accent);
    animation: ring-pulse 1.5s ease-in-out infinite;
}

.recording .btn-ring-1 { animation-delay: 0s; }
.recording .btn-ring-2 { animation-delay: 0.3s; }
.recording .btn-ring-3 { animation-delay: 0.6s; }

@keyframes ring-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.2;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.6;
    }
}

/* Main button */
.btn-record {
    position: relative;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(139, 92, 246, 0.05));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

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

.btn-record::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        var(--accent) 0%,
        transparent 20%,
        transparent 80%,
        var(--accent) 100%
    );
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s;
}

.recording .btn-record::before {
    opacity: 1;
    animation: rotate-glow 3s linear infinite;
}

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

.btn-record .icon {
    width: 40px;
    height: 40px;
    transition: all 0.3s;
}

.btn-record .icon svg {
    width: 100%;
    height: 100%;
    fill: var(--accent);
    transition: fill 0.3s;
}

.recording .btn-record {
    border-color: var(--error);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.2);
}

.recording .btn-record .icon svg {
    fill: var(--error);
}

/* Processing state */
.processing .btn-record {
    border-color: var(--accent-secondary);
    animation: processing-pulse 1s ease-in-out infinite;
}

.processing .btn-record .icon svg {
    fill: var(--accent-secondary);
    animation: spin 2s linear infinite;
}

@keyframes processing-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.2); }
    50% { box-shadow: 0 0 40px rgba(139, 92, 246, 0.4); }
}

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

/* Button label */
.btn-label {
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 20px;
    text-align: center;
    transition: color 0.3s;
}

.recording .btn-label {
    color: var(--error);
}

.processing .btn-label {
    color: var(--accent-secondary);
}

/* History / recent */
.history {
    width: 100%;
    flex-shrink: 0;
    padding-bottom: 16px;
}

.history-title {
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-align: center;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
}

.history-list::-webkit-scrollbar {
    width: 2px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border);
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:active {
    background: rgba(6, 182, 212, 0.08);
}

.history-item .badge {
    font-size: 9px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0;
}

.history-item .badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.history-item .text {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.history-item .time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Loading screen */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 24px;
    z-index: 100;
    transition: opacity 0.5s;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-screen .loader {
    width: 48px;
    height: 48px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-screen .text {
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 2px;
}

/* Start pulse */
.start-pulse {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    animation: start-pulse-anim 2s ease-in-out infinite;
    margin-bottom: 24px;
}

@keyframes start-pulse-anim {
    0%, 100% { transform: scale(1); opacity: 0.5; box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 30px 10px var(--accent-glow); }
}

/* Error toast */
.toast {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 20px) + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    border: 1px solid var(--error);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 50;
    transition: transform 0.3s;
    backdrop-filter: blur(20px);
    max-width: calc(100% - 48px);
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: var(--success);
}

/* Product tiles */
.product-tiles {
    width: 100%;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.product-tiles:empty {
    display: none;
}

.product-tiles::-webkit-scrollbar {
    height: 2px;
}

.product-tiles::-webkit-scrollbar-thumb {
    background: var(--border);
}

.product-tile {
    flex-shrink: 0;
    width: 140px;
    padding: 12px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    scroll-snap-align: start;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.product-tile:active {
    background: rgba(6, 182, 212, 0.1);
    border-color: var(--accent);
}

.product-tile .tile-name {
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-tile .tile-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
}

.product-tile .tile-unit {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.product-tile .tile-id {
    font-size: 9px;
    color: var(--text-muted);
    opacity: 0.6;
}

/* Action badge colors */
.badge-fakturoid { background: rgba(16, 185, 129, 0.15) !important; color: var(--success) !important; }
.badge-eshop { background: rgba(245, 158, 11, 0.15) !important; color: var(--warning) !important; }
.badge-email { background: rgba(139, 92, 246, 0.15) !important; color: var(--accent-secondary) !important; }
.badge-web { background: rgba(6, 182, 212, 0.15) !important; color: var(--accent) !important; }

/* PWA standalone */
@media (display-mode: standalone) {
    .header { padding-top: 12px; }
}

/* Small screens */
@media (max-height: 600px) {
    .btn-ring-1 { width: 160px; height: 160px; }
    .btn-ring-2 { width: 190px; height: 190px; }
    .btn-ring-3 { width: 220px; height: 220px; }
    .btn-record { width: 110px; height: 110px; }
    .btn-record .icon { width: 32px; height: 32px; }
    .response-text { font-size: 15px; max-height: 120px; }
}
