:root {
    /* Black & Gold Luxury Palette */
    --bg-dark: #0a0a0a;
    --bg-panel: #141414;
    --bg-card: #1f1f1f;
    --text-primary: #f8fafc;
    --text-secondary: #9ca3af;
    --accent-color: #D4AF37;
    --accent-hover: #F2C94C;
    --danger-color: #ef4444;
    --border-color: #2a2a2a;
    --panel-radius: 8px;
    --card-radius: 6px;
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
}

/* =========================================
   TOP NAVIGATION BAR
   ========================================= */
.topbar {
    height: 60px;
    background-color: var(--bg-panel);
    border-bottom: 2px solid var(--accent-color); /* Gold accent line */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-logo-img {
    height: 32px;
    width: 32px;
    object-fit: contain;
}

.topbar-logo h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.topbar-logo h2 span {
    color: var(--accent-color);
}

.topbar-controls {
    display: flex;
    align-items: center;
}

.topbar-select {
    width: 200px;
    padding: 8px 12px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--card-radius);
    font-size: 13px;
    cursor: pointer;
}

.topbar-select:focus {
    border-color: var(--accent-color);
    outline: none;
}

.divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
    margin: 0 16px;
}

/* =========================================
   MAIN LAYOUT (Sidebar + Content)
   ========================================= */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* SIDEBAR NAVIGATION */
.sidebar-nav {
    width: 250px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    flex-shrink: 0;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.nav-tab i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.nav-tab:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.02);
}

.nav-tab.active {
    color: var(--accent-color);
    background-color: rgba(212, 175, 55, 0.05); /* Very subtle gold tint */
    border-left-color: var(--accent-color);
}

.nav-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.nav-footer-credit {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 12px;
    opacity: 0.6;
}

.nav-footer-credit a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}

.nav-footer-credit a:hover {
    text-decoration: underline;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    margin-bottom: 8px;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border-color);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* WORKSPACE TABS */
.workspace {
    flex: 1;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-dark);
}

.tab-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.tab-content.active {
    opacity: 1;
    visibility: visible;
    z-index: 2;
}

/* =========================================
   GENERIC WORKSPACE CONTAINERS
   ========================================= */
.workspace-header {
    padding: 24px 40px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header-title h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.header-title p {
    font-size: 13px;
    color: var(--text-secondary);
}

.tab-body {
    padding: 40px;
    overflow-y: auto;
    flex-grow: 1;
}

/* =========================================
   STATES TAB CUSTOM LAYOUT
   ========================================= */
.states-layout-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.states-sidebar {
    width: 260px;
    min-width: 260px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.states-sidebar .workspace-header {
    padding: 15px 20px;
}

.states-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
}

.state-nav-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.state-nav-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.state-nav-item.active {
    background-color: rgba(212, 175, 55, 0.08); /* Gold tint */
    border-left: 3px solid var(--accent-color);
    color: var(--accent-light);
    font-weight: 500;
}

.states-main-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-dark);
}

/* =========================================
   FORMS & INPUTS
   ========================================= */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.input-group label small {
    color: #6b7280;
    font-weight: normal;
}

input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--card-radius);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px var(--accent-color);
}

textarea {
    resize: vertical;
    min-height: 60px;
}

/* Checkbox specific */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-dark);
    cursor: pointer;
    position: relative;
}

.checkbox-group input[type="checkbox"]:checked {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.checkbox-group input[type="checkbox"]:checked::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000;
    font-size: 10px;
}

.flex-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* =========================================
   BUTTONS
   ========================================= */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--card-radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--accent-color);
    color: #000; /* Black text on gold is very legible and premium */
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #2a2a2a;
    border-color: var(--text-secondary);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--accent-color);
    background-color: rgba(212, 175, 55, 0.1);
}


.btn-icon[class*="delete"]:hover,
.btn-icon[class*="remove"]:hover,
.btn-icon[class*="times"]:hover {
    color: var(--danger-color);
    background-color: rgba(239, 68, 68, 0.1);
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-text:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* =========================================
   DIALOGUE EDITOR (TAB 1)
   ========================================= */
.states-container {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    display: block; /* Standard block flow for vertical lists */
    width: 100%;
}

.state-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    display: none; 
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.3s border-color 0.3s;
    width: 100%;
    height: auto;
    min-height: 100%;
    margin-bottom: 2rem;
}

.state-card.active-card {
    display: block; /* Show as block */
}

.state-card:hover {
    border-color: #3f3f3f;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.state-header {
    background-color: var(--bg-card);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.state-id-input {
    background: transparent !important;
    border: none !important;
    color: var(--accent-color) !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    padding: 0 !important;
    box-shadow: none !important;
    width: 200px !important;
}

.state-id-input:focus {
    color: var(--accent-hover) !important;
}

.state-body {
    padding: 20px;
    width: 100%;
}

/* Choices */
.choices-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    width: 100%;
    max-width: 100%;
}

.choices-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.choices-header h4 {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.choices-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 100%;
}

.choice-item {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: 12px;
    width: 100%;
    max-width: 100%;
}

.choice-top {
    display: grid;
    grid-template-columns: 1fr 140px 40px; /* Reduced next-input width to give more space to text */
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    width: 100%;
}

.choice-bottom {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
    width: 100%;
}

.choice-text-input {
    width: 100%;
}
.choice-next-input { 
    width: 100%; 
}
.choice-predicate-input { 
    width: 100%;
}

.btn-delete-choice {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    width: 32px;
}

/* =========================================
   LIST & CONFIG CARDS (OTHER TABS)
   ========================================= */
.config-card,
.list-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--panel-radius);
    padding: 24px;
    max-width: 800px;
    margin: 0 auto;
}

.item-list {
    list-style: none;
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-list li {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: 16px;
}/* Utilities */
.hidden {
    display: none !important;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem;
    opacity: 0.6;
}

.empty-state i {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    color: var(--border-color);
}

@media (max-width: 900px) {
    .hide-mobile {
        display: none;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}