/**
 * FOVCalc 3D - Premium Stylesheet
 * Author: Sandro Benigno (EvilPlaymobil)
 * License: GNU General Public License v3.0 (GNU GPL v3)
 * Copyright (c) 2026 Sandro Benigno
 * Version: 1.1 - Mobile Layout Fix
 */

:root {
    --bg-base: #0a0e17;
    --bg-surface: rgba(18, 24, 38, 0.7);
    --bg-surface-opaque: #121826;
    --bg-card: rgba(26, 34, 53, 0.45);
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Accents */
    --accent-primary: #3b82f6; /* Blue */
    --accent-hfov: #00f2fe;    /* Cyan */
    --accent-vfov: #f355da;    /* Pink-Magenta */
    --accent-hfw: #00f5a0;     /* Emerald Green */
    --accent-vfw: #ffaf40;     /* Orange-Amber */
    
    --glow-opacity: 0.15;
    
    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* App Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    position: relative;
    background: radial-gradient(circle at 75% 20%, #1e1b4b 0%, var(--bg-base) 60%);
}

/* Sidebar Controls */
.sidebar {
    width: 380px;
    min-width: 380px;
    height: 100%;
    background-color: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.25);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

/* Seletor de Idiomas */
.lang-selector {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    gap: 4px;
    background: rgba(10, 14, 23, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px;
}

.lang-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    outline: none;
}

.lang-btn:hover {
    color: var(--text-primary);
}

.lang-btn.active {
    background: var(--accent-primary);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--accent-hfov);
    filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.5));
    animation: rotateLogo 20s linear infinite;
}

@keyframes rotateLogo {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.logo h1 {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo h1 span {
    font-weight: 400;
    font-size: 14px;
    background: linear-gradient(135deg, var(--accent-hfov), var(--accent-vfov));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

.heart-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    color: #ef4444;
    vertical-align: middle;
    fill: #ef4444;
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Control Groups */
.control-group {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.control-group:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.group-title i {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

.group-title h2 {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.group-subtitle {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 16px 0 8px 0;
    font-weight: 600;
}

/* Form Fields */
.input-field {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-field:last-child {
    margin-bottom: 0;
}

label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

select, input[type="number"], input[type="text"] {
    background-color: rgba(10, 14, 23, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 5px 8px;
    font-family: var(--font-body);
    font-size: 12px;
    outline: none;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Ocultar as setas (spinners) padrão nos campos numéricos para economizar espaço */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

select:focus, input[type="number"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
    padding-right: 28px;
}

.grid-2-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

.grid-3-cols {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.grid-3-cols:last-child {
    margin-bottom: 0;
}

/* Sliders */
.range-with-input {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-with-input input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    height: 4px;
    border-radius: 2px;
    outline: none;
}

.range-with-input input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
    transition: transform 0.1s;
}

.range-with-input input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-with-input input[type="number"] {
    width: 55px;
    padding: 4px 6px;
    text-align: center;
}

/* Segmented Control / Radio Buttons */
.segmented-control {
    display: flex;
    background: rgba(10, 14, 23, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px;
    position: relative;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
    user-select: none;
}

.segmented-control input[type="radio"]:checked + label {
    background-color: var(--accent-primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Mini Stats */
.mini-stats {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 10px;
    border-top: 1px dashed rgba(255, 255, 255, 0.05);
    padding-top: 8px;
}

.mini-stats span {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Main Workspace */
.main-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* 3D Canvas container */
#canvas-container {
    flex: 1;
    position: relative;
    width: 100%;
    background-color: #05070c;
}

#three-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* HUD controls */
.canvas-hud-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 5;
}

.canvas-hud-controls button {
    background: rgba(18, 24, 38, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 8px 14px;
    font-family: var(--font-body);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    outline: none;
}

.canvas-hud-controls button:hover {
    border-color: var(--border-hover);
    background: rgba(26, 34, 53, 0.95);
    transform: translateY(-1px);
}

.canvas-hud-controls button.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.canvas-hud-controls button i {
    width: 14px;
    height: 14px;
}

/* Results Dashboard Overlay */
.results-dashboard {
    height: 72px;
    min-height: 72px;
    border-top: 1px solid var(--border-color);
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 8px 16px;
    z-index: 5;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.result-card:hover {
    transform: translateY(-1px);
    border-color: var(--border-hover);
}

.result-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.result-icon-wrapper i {
    width: 15px;
    height: 15px;
}

.result-data h3 {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.result-data .value {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.result-data .description {
    font-size: 9px;
    color: var(--text-muted);
}

/* Accent Card Configurations */
.accent-hfov { border-left: 3px solid var(--accent-hfov); }
.accent-hfov .result-icon-wrapper { color: var(--accent-hfov); background: rgba(0, 242, 254, 0.05); }
.accent-hfov .value { color: var(--accent-hfov); text-shadow: 0 0 10px rgba(0, 242, 254, var(--glow-opacity)); }

.accent-vfov { border-left: 3px solid var(--accent-vfov); }
.accent-vfov .result-icon-wrapper { color: var(--accent-vfov); background: rgba(243, 85, 218, 0.05); }
.accent-vfov .value { color: var(--accent-vfov); text-shadow: 0 0 10px rgba(243, 85, 218, var(--glow-opacity)); }

.accent-hfw { border-left: 3px solid var(--accent-hfw); }
.accent-hfw .result-icon-wrapper { color: var(--accent-hfw); background: rgba(0, 245, 160, 0.05); }
.accent-hfw .value { color: var(--accent-hfw); text-shadow: 0 0 10px rgba(0, 245, 160, var(--glow-opacity)); }

.accent-vfw { border-left: 3px solid var(--accent-vfw); }
.accent-vfw .result-icon-wrapper { color: var(--accent-vfw); background: rgba(255, 175, 64, 0.05); }
.accent-vfw .value { color: var(--accent-vfw); text-shadow: 0 0 10px rgba(255, 175, 64, var(--glow-opacity)); }

/* HUD Legendinha Flutuante */
.canvas-legend-hud {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(18, 24, 38, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: var(--font-heading);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.hud-item {
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.hud-item span {
    font-family: var(--font-body);
    font-weight: 400;
}

.hfov-hud {
    color: var(--accent-hfov);
    text-shadow: 0 0 8px rgba(0, 242, 254, 0.2);
}

.vfov-hud {
    color: var(--accent-vfov);
    text-shadow: 0 0 8px rgba(243, 85, 218, 0.2);
}

/* Responsive adjustments */
@media (max-width: 900px) and (orientation: portrait) {
    /* Mobile Portrait (Vertical) */
    .app-container {
        flex-direction: column-reverse;
        overflow: hidden;
    }
    
    .sidebar {
        width: 100%;
        min-width: 100%;
        height: 48vh;
        min-height: 48vh;
        position: static; /* Permite que o cabeçalho se alinhe ao app-container topo */
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border-right: none;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
    }
    
    .sidebar-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 56px;
        background: var(--bg-surface);
        z-index: 100; /* Garante que fica por cima do canvas */
        border-bottom: 1px solid var(--border-color);
        padding: 0 16px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        box-sizing: border-box;
    }
    
    .sidebar-header .credits, 
    .sidebar-header .tutorial-link {
        display: none;
    }
    
    .main-workspace {
        height: 52vh;
        min-height: 52vh;
        padding-top: 56px; /* Empurra o canvas e HUD para baixo do cabeçalho fixo */
        box-sizing: border-box;
        flex: none;
        display: flex;
        flex-direction: column;
    }
    
    .card-sub-title {
        display: none !important;
    }
    
    #canvas-container {
        flex: 1;
    }

    /* Botões do HUD compactos (Apenas Ícones no celular) */
    .canvas-hud-controls {
        top: 10px;
        right: 10px;
        gap: 6px;
    }
    .canvas-hud-controls button {
        padding: 8px;
    }
    .canvas-hud-controls button span {
        display: none;
    }
    
    /* Dashboard de resultados ultra-compacto em uma linha horizontal */
    .results-dashboard {
        grid-template-columns: repeat(4, 1fr) !important;
        height: 42px;
        min-height: 42px;
        border-top: 1px solid var(--border-color);
        background: #090d16;
    }

    .result-card {
        padding: 4px;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        border-bottom: none !important;
        border-left: 1px solid var(--border-color) !important;
    }

    .result-card:first-child {
        border-left: none !important;
    }

    .result-icon-wrapper, 
    .result-card .description {
        display: none !important; /* Oculta ícones e descrições no celular retrato */
    }

    .result-data {
        display: flex;
        flex-direction: row;
        align-items: baseline;
        gap: 4px;
    }

    .result-data h3 {
        font-size: 8px;
        margin: 0;
    }

    .result-data .value {
        font-size: 13px;
        font-weight: 700;
    }
    
    .logo h1 {
        font-size: 20px;
    }
    .logo-icon {
        width: 20px;
        height: 20px;
    }
    .lang-selector {
        top: 14px;
        right: 16px;
    }
    
    .scrollable-content {
        padding: 12px;
        gap: 12px;
    }
    
    .control-group {
        padding: 12px;
    }

    /* Melhora o espaçamento de inputs para toque */
    input[type="range"] {
        height: 32px;
    }
    .range-with-input input[type="number"] {
        width: 55px;
        height: 32px;
        font-size: 13px;
    }
    .grid-3-cols input, .grid-2-cols input, select {
        height: 36px;
        font-size: 13px;
    }
}

@media (max-width: 950px) and (orientation: landscape) {
    /* Mobile Landscape (Horizontal) */
    .sidebar {
        width: 290px;
        min-width: 290px;
    }
    
    .logo h1 {
        font-size: 18px;
    }
    .logo h1 span {
        font-size: 11px;
    }
    
    .sidebar-header {
        padding: 12px 16px;
    }
    .lang-selector {
        top: 12px;
        right: 16px;
    }
    
    .scrollable-content {
        padding: 8px 12px;
        gap: 8px;
    }
    
    .control-group {
        padding: 10px;
        margin-bottom: 4px;
    }
    
    .group-title h2 {
        font-size: 12px;
    }
    .group-title i {
        width: 14px;
        height: 14px;
    }
    
    .results-dashboard {
        height: 64px;
        min-height: 64px;
    }
    .result-data .value {
        font-size: 14px;
    }
    .result-data h3 {
        font-size: 8px;
    }
    .result-icon-wrapper {
        width: 24px;
        height: 24px;
    }
}
