/**
 * V3 CSS Overrides & Enhancements
 * Extends V2 style with V3-specific improvements
 */

/* ===== V3 Specific Overrides ===== */

/* Ensure V3 styling coexists with V2 */
:root {
    /* V3 additions */
    --v3-accent: #22D3EE;
    --v3-glow: 0 0 20px rgba(34, 211, 238, 0.3);
}

/* ===== TOP TOOLBAR (glassmorphism - transparent) ===== */
#top-toolbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 60px !important;
    background: rgba(30, 41, 59, 0.7) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 15px !important;
    z-index: 100 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: none !important;
}

/* ===== CANVAS WATERMARK ===== */
#canvas-watermark {
    position: absolute;
    top: 15px;
    left: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 50;
    pointer-events: none;
    /* No afecta el canvas */
    user-select: none;
    opacity: 0.7;
    transition: opacity 0.3s;
}

#canvas-watermark:hover {
    opacity: 1;
}

#canvas-watermark .wm-icon {
    font-size: 18px;
}

#canvas-watermark .wm-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

#canvas-watermark .wm-version {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--accent-cyan);
    color: var(--bg-primary);
    border-radius: 4px;
    font-weight: 600;
}

.ntm-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ntm-brand .icon {
    font-size: 22px;
    color: var(--accent-green);
}

.ntm-brand .brand-text {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

.v3-badge {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--accent-cyan);
    color: var(--bg-primary);
    border-radius: 4px;
    font-weight: 600;
}

/* Icon-based navigation */
.ntm-icon-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-icon-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.menu-icon-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.menu-icon-btn:active {
    transform: scale(0.95);
}

.menu-icon-btn .btn-icon {
    font-size: 20px;
}

.menu-separator {
    width: 1px;
    height: 30px;
    background: var(--border-color);
    margin: 0 8px;
}

/* Status indicator */
.ntm-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #666;
}

.status-indicator.online {
    background: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Hamburger for mobile */
.ntm-hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
}

.ntm-hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .ntm-icon-nav {
        display: none;
    }

    .ntm-hamburger {
        display: flex !important;
    }

    .ntm-icon-nav.mobile-open {
        display: flex !important;
        position: fixed;
        top: 56px;
        left: 10px;
        right: 10px;
        background: rgba(30, 41, 59, 0.98);
        backdrop-filter: blur(10px);
        padding: 12px;
        border-radius: 12px;
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
        z-index: 1050;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    }

    .ntm-status .status-text {
        display: none;
    }
}

/* Ensure panels have proper floating-panel class */
#lectura-panel,
#material-panel,
#offsets-panel,
#bp-panel {
    /* Inherit from floating-panel in v2-style.css */
}

/* V3 Panel Header Style */
.floating-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    cursor: move;
    user-select: none;
    border-bottom: 1px solid var(--border-color);
}

.floating-panel .panel-header h3 {
    margin: 0;
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
}

.floating-panel .panel-controls {
    display: flex;
    gap: 6px;
}

.floating-panel .panel-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.floating-panel .panel-btn:hover {
    background: var(--accent-green);
    color: var(--bg-primary);
}

/* Collapse behavior */
.floating-panel.collapsed .panel-content,
.floating-panel.collapsed .resize-handle {
    display: none !important;
}

.floating-panel.collapsed {
    min-height: auto !important;
    height: auto !important;
}

/* DRO Section Titles */
.dro-section {
    margin-bottom: 12px;
}

.dro-section-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Playback buttons (V3 style) */
.playback-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.playback-btn:hover {
    background: var(--accent-green);
    color: var(--bg-primary);
    transform: scale(1.1);
}

.playback-btn:active {
    transform: scale(0.95);
}

/* Toggle Switch (iOS style) */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    border-radius: 24px;
    transition: 0.3s;
    border: 1px solid var(--border-color);
}

.toggle-switch .slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked+.slider {
    background: var(--accent-green);
    border-color: var(--accent-green);
}

.toggle-switch input:checked+.slider::before {
    transform: translateX(20px);
    background: white;
}

/* Offset Panel */
.offset-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.offset-selector label {
    font-size: 12px;
    color: var(--text-secondary);
}

.offset-selector select {
    flex: 1;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
}

.offset-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.offset-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.offset-input label {
    width: 20px;
    font-weight: 600;
    color: var(--text-secondary);
}

.offset-input input {
    flex: 1;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: 'Consolas', monospace;
}

.offset-btn {
    width: 100%;
    padding: 10px;
    background: var(--accent-green);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.offset-btn:hover {
    background: #0EA571;
    transform: translateY(-1px);
}

/* ===== LAYERS PANEL STYLES ===== */
.layers-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.layer-action-btn {
    flex: 1;
    padding: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.layer-action-btn:hover {
    background: var(--accent-cyan);
    color: var(--bg-primary);
    transform: translateY(-1px);
}

.layers-count {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.layers-count strong {
    color: var(--accent-cyan);
}

.layers-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s;
}

.layer-item:last-child {
    border-bottom: none;
}

.layer-item:hover {
    background: rgba(34, 211, 238, 0.1);
}

.layer-item.selected {
    background: rgba(34, 211, 238, 0.2);
    border-left: 3px solid var(--accent-cyan);
}

.layer-item.layer-header {
    background: var(--bg-secondary);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    cursor: default;
}

.layer-item.layer-header:hover {
    background: var(--bg-secondary);
}

.layer-icon {
    width: 24px;
    text-align: center;
    cursor: pointer;
}

.layer-icon:hover {
    transform: scale(1.2);
}

.layer-name {
    flex: 1;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-type {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--bg-secondary);
    border-radius: 4px;
    color: var(--text-secondary);
}

.layer-item.hidden-object .layer-name {
    opacity: 0.5;
    text-decoration: line-through;
}

/* Canvas now covers full screen (behind transparent toolbars) */
#canvasContainer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    z-index: 1;
    background: linear-gradient(135deg, #0a0f14 0%, #151d27 100%);
    overflow: hidden;
}

/* Bottom menu (transparent) */
#bottomMenu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    padding: 0 15px;
    z-index: 100;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
    color: var(--text-secondary);
}

/* Mobile drawer tabs - Bottom Toolbar (transparent) */
#mobile-drawer-tabs {
    position: fixed !important;
    bottom: 30px !important;
    left: 0 !important;
    right: 0 !important;
    height: 60px !important;
    background: rgba(30, 41, 59, 0.7) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 15px !important;
    z-index: 100 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: none !important;
}

/* V3 Badge on brand */
.ntm-brand small {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--accent-cyan);
    color: var(--bg-primary);
    border-radius: 4px;
    margin-left: 4px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ntm-nav {
        display: none;
    }

    .ntm-hamburger {
        display: flex !important;
    }

    #canvasContainer {
        bottom: 95px !important;
    }
}