:root {
    --bg-color: #0d0d0d;
    --card-bg: #151515;
    --text-main: #ffffff;
    --text-secondary: #888888;
    --accent-purple: #7b61ff;
    --accent-green: #00d1a0;
    --border-color: #222222;
    --input-bg: #1c1c1c;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color); /* Changed from --bg-dark to --bg-color to match existing variables */
    margin: 0;
    font-family: 'Outfit', sans-serif;
    color: white;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Base Layout for Sidebar + Main Content */
.app-layout {
    display: flex;
    width: 100%;
    flex: 1;
    overflow: hidden;
    height: 100vh;
}

.sidebar {
    width: 280px;
    background-color: #0d0d18;
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    padding: 20px 15px;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 20px;
}

.btn-new-project {
    width: 100%;
    background: #1e1e2d;
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
}
.btn-new-project:hover {
    background: #2a2a3e;
    border-color: rgba(255,255,255,0.2);
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tree-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
    color: var(--text-secondary);
    font-weight: 600;
}
.tree-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}
.tree-item.active {
    background: rgba(123, 97, 255, 0.15);
    color: var(--accent-purple);
}

.tree-item-name {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tree-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}
.tree-item:hover .tree-actions {
    opacity: 1;
}

.tree-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 5px;
    border-radius: 5px;
}
.tree-btn:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.tree-subfolders {
    padding-left: 20px;
    display: none; /* Escondido por padrão para o efeito cascata */
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.05);
    margin: 20px 0;
}

.sidebar-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.sidebar-links li {
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: background 0.2s, color 0.2s;
}
.sidebar-links li:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

header {
    width: 100%;
    /*max-width: 1400px;*/
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.logo span {
    background: linear-gradient(135deg, #7b61ff, #00d1a0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.badge {
    background: var(--card-bg);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
}

.badge b { color: #fff; }

.btn-primary {
    background: var(--accent-green);
    color: #000;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-primary:hover {
    transform: scale(1.05);
}

main {
    flex: 1;
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 550px 1fr;
    gap: 40px;
    padding: 30px 40px;
}

.panel {
    background: linear-gradient(145deg, #151515, #1a1a1a);
    border-radius: 24px;
    padding: 35px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

h3 {
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.upload-box {
    border: 2px dashed #333;
    border-radius: 15px;
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.3s;
    position: relative;
    overflow: hidden;
}

.upload-box:hover {
    border-color: var(--accent-purple);
}

.upload-box i { font-size: 2rem; margin-bottom: 10px; }

.controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Alvo de Atenção - UX Guide */
.form-field.attention {
    background: rgba(123, 97, 255, 0.05);
    border: 1px solid rgba(123, 97, 255, 0.2);
    border-radius: 16px;
    padding: 20px;
    margin: 10px 0;
    box-shadow: 0 0 20px rgba(123, 97, 255, 0.1);
    animation: pulseGlow 3s infinite ease-in-out;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 10px rgba(123, 97, 255, 0.1); border-color: rgba(123, 97, 255, 0.2); }
    50% { box-shadow: 0 0 25px rgba(123, 97, 255, 0.2); border-color: rgba(123, 97, 255, 0.4); }
    100% { box-shadow: 0 0 10px rgba(123, 97, 255, 0.1); border-color: rgba(123, 97, 255, 0.2); }
}

.form-field.attention label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #b3a4ff;
    font-weight: 800;
}

.form-field.attention label::before {
    content: "💡";
    font-size: 1.2rem;
}

.form-field.attention textarea {
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.05);
    margin-top: 5px;
}

label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

select, textarea, input[type="text"] {
    background: var(--input-bg);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 14px;
    color: #fff;
    width: 100%;
    font-size: 0.95rem;
    transition: all 0.3s;
}

select:focus, textarea:focus, input[type="text"]:focus {
    border-color: var(--accent-purple);
    outline: none;
    box-shadow: 0 0 10px rgba(123, 97, 255, 0.1);
}

.btn-generate {
    background: var(--accent-purple);
    color: #fff;
    border: none;
    padding: 20px;
    border-radius: 15px;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    width: 100%;
    margin-top: 20px;
    box-shadow: 0 10px 20px rgba(123, 97, 255, 0.3);
    transition: all 0.3s;
}

.btn-generate:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
}

/* Custom Select Aspect Ratio */
.custom-select {
    position: relative;
    width: 100%;
}

.select-trigger {
    background: var(--input-bg);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 12px 14px;
    color: #fff;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.select-trigger:hover {
    border-color: rgba(255,255,255,0.15);
}

.select-trigger::after {
    content: "▼";
    font-size: 0.7rem;
    color: #555;
    transition: transform 0.3s;
}

.custom-select.active .select-trigger::after {
    transform: rotate(180deg);
}

.options-list {
    position: absolute;
    bottom: calc(100% + 8px);
    top: auto !important;
    left: 0;
    width: 320px;
    background: #0f1115;
    border: 1px solid #222;
    border-radius: 16px;
    box-shadow: 0 -20px 50px rgba(0,0,0,0.8);
    display: none;
    z-index: 1000;
    max-height: 380px;
    overflow-y: auto;
    padding: 8px;
}

.custom-select.active .options-list {
    display: block;
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.option-item {
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.2s;
}

.option-item:hover {
    background: rgba(255,255,255,0.05);
}

.option-item.selected {
    background: rgba(123, 97, 255, 0.1);
    border: 1px solid rgba(123, 97, 255, 0.2);
}

.ratio-icon {
    width: 24px;
    height: 24px;
    border: 1.5px solid #555;
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.option-info {
    display: flex;
    flex-direction: column;
}

.option-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
}

.option-desc {
    font-size: 0.75rem;
    color: #666;
}

/* Scrollbar Custom */
.options-list::-webkit-scrollbar { width: 5px; }
.options-list::-webkit-scrollbar-track { background: transparent; }
.options-list::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.hierarchy-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.project-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.03);
    padding: 5px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

.project-selector select {
    background: transparent;
    border: none;
    padding: 5px;
    font-size: 0.85rem;
    color: var(--accent-purple);
    font-weight: 700;
    cursor: pointer;
    width: auto;
    min-width: 130px;
    max-width: 200px;
}

.action-btns {
    display: flex;
    gap: 5px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--accent-purple);
    background: rgba(123, 97, 255, 0.15);
    transform: scale(1.15);
    box-shadow: 0 0 10px rgba(123, 97, 255, 0.2);
}

.result-placeholder {
    flex: 1;
    min-height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #444;
    font-size: 1.1rem;
    background: #080808;
    background-image: radial-gradient(circle at center, #111 0%, #080808 100%);
    border: 1px solid #222;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.8);
    position: relative;
    padding: 20px;
}
.viewport-badge {
    position: absolute;
    top: 15px;
    left: 20px;
    font-size: 0.6rem;
    color: #333;
    font-weight: 800;
    letter-spacing: 2px;
    z-index: 20;
    pointer-events: none;
}

.result-placeholder img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

/* ── History Context Menu ── */
.hctx-card {
    background: #1a1a2e;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 6px;
    min-width: 200px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04);
    backdrop-filter: blur(12px);
    animation: ctxFadeIn 0.15s ease-out;
}

@keyframes ctxFadeIn {
    from { opacity: 0; transform: scale(0.95) translateY(-4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.hctx-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: none;
    border: none;
    color: #e0e0e0;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 11px 14px;
    border-radius: 9px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.hctx-item:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
}

.hctx-icon {
    font-size: 1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

/* ── History Section ── */
.history-section {
    padding: 25px 40px 30px;
    border-top: 1px solid var(--border-color);
}

.history-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.history-grid::-webkit-scrollbar { height: 5px; }
.history-grid::-webkit-scrollbar-track { background: transparent; }
.history-grid::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }

.history-item {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: #0d0d0d;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
}

.history-item:hover {
    transform: scale(1.02);
    border-color: var(--accent-purple);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* =============================================
   RESPONSIVE - Mobile, Tablet, Notebook
   ============================================= */

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 99;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.sidebar-overlay.active { display: block; }

/* Hamburger button (hidden on desktop) */
.btn-hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    line-height: 1;
    transition: background 0.2s;
    flex-shrink: 0;
}
.btn-hamburger:hover { background: rgba(255,255,255,0.08); }

/* ── Notebook (≤1200px) ── */
@media (max-width: 1200px) {
    main {
        grid-template-columns: 460px 1fr;
        gap: 25px;
        padding: 20px 25px;
    }
}

/* ── Tablet landscape (≤1024px) ── */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -290px;
        top: 0;
        height: 100vh;
        z-index: 100;
        transition: left 0.3s cubic-bezier(.4,0,.2,1);
        box-shadow: 4px 0 30px rgba(0,0,0,0.6);
    }
    .sidebar.open { left: 0; }
    .btn-hamburger { display: flex; align-items: center; justify-content: center; }
    main {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        padding: 20px;
    }
    header { padding: 15px 20px; }
}

/* ── Tablet portrait / large phones (≤768px) ── */
@media (max-width: 768px) {
    .app-layout { overflow: visible; height: auto; min-height: 100vh; }
    .main-content { height: auto; min-height: 100vh; overflow-y: visible; }

    header {
        padding: 12px 15px;
        gap: 8px;
    }
    .logo { font-size: 1.3rem; }
    .user-info {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .badge { font-size: 0.75rem; padding: 5px 10px; }
    .btn-primary { padding: 8px 12px; font-size: 0.78rem; }

    main {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 12px;
    }
    .panel { padding: 20px; border-radius: 18px; }
    .upload-grid { grid-template-columns: 1fr; }
    .controls-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .options-list { width: calc(100vw - 30px); left: 0; }

    .history-section { padding: 15px 12px 20px; }
    .history-item { width: 160px; height: 160px; }

    .panel-header { gap: 10px; }
    .hierarchy-controls { flex-wrap: wrap; gap: 8px; }
}

/* ── Small phones (≤480px) ── */
@media (max-width: 480px) {
    header { padding: 10px 12px; }
    .logo { font-size: 1.1rem; }
    .badge:nth-child(1) { display: none; } /* hide plan badge to save space */
    .btn-primary { font-size: 0.72rem; padding: 7px 10px; }

    main { padding: 10px; gap: 12px; }
    .panel { padding: 14px; border-radius: 14px; }
    .controls-row { grid-template-columns: 1fr; }
    .btn-generate { padding: 16px; font-size: 1rem; }

    .history-item { width: 130px; height: 130px; }
    .history-section { padding: 12px 10px; }

    .upload-box { height: 150px; }
    .result-placeholder { min-height: 300px; }
}
