:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-card: #2f2f2f;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent: #4a90e2;
    --accent-hover: #5aa0f2;
    --success: #4caf50;
    --danger: #f44336;
    --border: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding-top: 1rem;
    padding-bottom: 80px; /* Space for mobile bottom nav */
}

#app {
    min-height: 100vh;
}

/* Navbar - Mobile First */
.navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0.5rem 0;
    z-index: 1000;
    box-shadow: 0 -2px 8px var(--shadow);
}

.navbar-brand {
    display: none; /* Hidden on mobile */
}

.navbar-menu {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 0.25rem;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.navbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all 0.2s;
    flex: 1;
    max-width: 80px;
    min-width: 60px;
    position: relative;
}

.navbar-item:active {
    transform: scale(0.95);
    opacity: 0.7;
}

.navbar-item.active {
    color: var(--accent);
}

.navbar-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background-color: var(--accent);
    border-radius: 0 0 3px 3px;
}

.navbar-icon {
    font-size: 1.5rem;
}

.navbar-text {
    font-size: 0.7rem;
    font-weight: 500;
    text-align: center;
}

.navbar-text .text-long {
    display: none;
}

.navbar-text .text-short {
    display: inline;
}

.navbar-user {
    display: none; /* Hidden on mobile, shown in top header instead */
}

.navbar-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.navbar-user-icon {
    font-size: 1.2rem;
}

.navbar-user-name {
    display: inline;
}

.navbar-logout {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar-logout:hover {
    background-color: var(--bg-card);
    color: var(--danger);
}

.navbar-logout:active {
    transform: scale(0.95);
}

/* Mobile top header for user info */
.mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px var(--shadow);
}

.mobile-header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.1rem;
}

.mobile-header-logo {
    font-size: 1.3rem;
}

.mobile-header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mobile-header-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.mobile-header-user-info .navbar-user-icon {
    font-size: 1.1rem;
}

/* Hide navbar on login page - handled by JavaScript */
#navbar-container:empty {
    display: none;
}

/* Adjust body padding when mobile header is present */
body.has-mobile-header {
    padding-top: 60px;
}

/* Desktop Styles - 768px and up */
@media (min-width: 768px) {
    body {
        padding-top: 70px;
        padding-bottom: 20px;
    }
    
    body.has-mobile-header {
        padding-top: 70px;
    }
    
    /* Hide mobile header on desktop */
    .mobile-header {
        display: none;
    }
    
    /* Desktop navbar - move to top */
    .navbar {
        top: 0;
        bottom: auto;
        height: 60px;
        border-top: none;
        border-bottom: 1px solid var(--border);
        padding: 0 1.5rem;
        justify-content: space-between;
        box-shadow: 0 2px 8px var(--shadow);
    }
    
    .navbar-brand {
        display: flex;
    }
    
    .navbar-logo {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        text-decoration: none;
        color: var(--text-primary);
        font-weight: 600;
        font-size: 1.1rem;
        transition: opacity 0.2s;
    }
    
    .navbar-logo:hover {
        opacity: 0.8;
    }
    
    .navbar-logo-icon {
        font-size: 1.3rem;
    }
    
    .navbar-logo-text {
        display: inline;
    }
    
    .navbar-menu {
        flex: 1;
        justify-content: center;
        gap: 0.5rem;
        max-width: none;
    }
    
    .navbar-item {
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
        min-width: auto;
        max-width: none;
        flex: none;
    }
    
    .navbar-item:hover {
        background-color: var(--bg-card);
        color: var(--text-primary);
    }
    
    .navbar-item:active {
        transform: none;
    }
    
    .navbar-item.active {
        background-color: rgba(74, 144, 226, 0.1);
    }
    
    .navbar-item.active::before {
        display: none;
    }
    
    .navbar-icon {
        font-size: 1.3rem;
    }
    
    .navbar-text {
        font-size: 0.9rem;
    }
    
    .navbar-text .text-long {
        display: inline;
    }
    
    .navbar-text .text-short {
        display: none;
    }
    
    .navbar-user {
        display: flex;
    }
    
    .navbar-user-name {
        display: inline;
    }
    
    .navbar-logout:hover {
        background-color: var(--bg-card);
        color: var(--danger);
    }
}

.container {
    max-width: 100%;
    padding: 1rem;
    padding-bottom: 1.5rem; /* Extra space at bottom for mobile nav */
}

.page {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.page.active {
    display: block;
}

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

/* Header */
.header {
    background-color: transparent;
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header .subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px var(--shadow);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-content {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Collapsible Card Styles */
.card-header-collapsible {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 0;
    gap: 0.5rem;
}

.card-header-collapsible::before {
    content: '▶';
    transition: transform 0.2s;
    color: var(--accent);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.card.open .card-header-collapsible::before {
    transform: rotate(90deg);
}

.card-collapsible-content {
    display: none;
    margin-top: 1rem;
}

.card.open .card-collapsible-content {
    display: block;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

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

.btn-secondary:hover {
    background-color: var(--bg-card);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #e53935;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #45a049;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

.form-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.info-box {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.info-box p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.info-box p:last-child {
    margin-bottom: 0;
}

.section-subtitle {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.section-subtitle:first-child {
    margin-top: 0;
}

/* Settings Modules (Accordion) */
.settings-module {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.module-header {
    padding: 1rem 1.5rem;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    user-select: none;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.module-header:hover {
    background-color: var(--bg-card);
}

.module-header::marker {
    content: '';
}

.module-header::-webkit-details-marker {
    display: none;
}

.module-header::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.75rem;
    transition: transform 0.2s;
    color: var(--accent);
}

details[open] > .module-header::before {
    transform: rotate(90deg);
}

.module-content {
    padding: 1.5rem;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-textarea {
    resize: both;
    min-height: 100px;
}

/* User Cards (Login) */
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.user-card {
    background-color: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.user-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.user-card.active {
    border-color: var(--accent);
    background-color: rgba(74, 144, 226, 0.1);
}

.user-card .user-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

/* Navigation Cards */
.nav-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.nav-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.nav-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.nav-card-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.nav-card-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.nav-card-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Product List */
.product-list {
    margin-top: 1rem;
}

.product-item {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.product-item:hover {
    border-color: var(--accent);
    transform: translateX(4px);
}

.product-item.has-user-notes {
    border-left: 4px solid var(--accent);
    background-color: rgba(74, 144, 226, 0.05);
}

.product-item.has-open-questions {
    border-left: 4px solid #e6a800;
    background-color: rgba(230, 168, 0, 0.05);
}

.product-item.has-user-notes.has-open-questions {
    border-left: 4px solid #e6a800;
}

.product-open-question-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: #e6a800;
    color: #1a1a1a;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.product-expand-questions-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.product-expand-questions-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.product-open-questions-expanded {
    display: none;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.product-open-questions-expanded.open {
    display: block;
}

.product-open-question-expanded-item {
    font-size: 0.9rem;
    color: var(--text-primary);
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
}

.product-open-question-expanded-item:last-child {
    border-bottom: none;
}

.product-note-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: var(--accent);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.product-note-badge-others {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: var(--success);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.product-uploaded-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: var(--text-secondary, #666);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.product-item-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}


/* Open Questions (detail page) */
.open-questions-list {
    margin-bottom: 0;
}

.open-question-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.open-question-item:last-child {
    border-bottom: none;
}

.open-question-text {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.open-question-remove {
    flex-shrink: 0;
}

.btn-sm {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

/* Notes */
.notes-list {
    margin-top: 1rem;
}

.notes-tabs-container {
    margin-top: 1rem;
}

.notes-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.notes-tabs::-webkit-scrollbar {
    height: 4px;
}

.notes-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.notes-tabs::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 2px;
}

.notes-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    margin-bottom: -2px;
}

.notes-tab:hover {
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    border-radius: 8px 8px 0 0;
}

.notes-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.notes-tab-count {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
}

.notes-tab.active .notes-tab-count {
    background-color: var(--accent);
    color: white;
}

.notes-tab-contents {
    position: relative;
    min-height: 100px;
}

.notes-tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.notes-tab-content.active {
    display: block;
}

.note-item {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    position: relative;
}

.note-item.own-note {
    border-left: 4px solid var(--accent);
}

.note-item .note-author {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.note-item .note-text {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.note-item .note-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.note-item .note-actions button {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.note-item .note-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Voice Recording */
.voice-recorder {
    position: fixed;
    bottom: 100px; /* Above mobile navbar */
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
}

@media (min-width: 768px) {
    .voice-recorder {
        bottom: 30px; /* Lower on desktop */
    }
}

.record-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background-color: var(--danger);
    color: white;
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(244, 67, 54, 0.4);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.record-btn.recording {
    animation: pulse 1.5s infinite;
    background-color: var(--danger);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 16px rgba(244, 67, 54, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 24px rgba(244, 67, 54, 0.6);
    }
}

.transcription-display {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    min-height: 60px;
    max-height: 200px;
    overflow-y: auto;
    color: var(--text-secondary);
    font-style: italic;
    scroll-behavior: smooth;
}

.transcription-display.active {
    color: var(--text-primary);
    font-style: normal;
}

.note-text-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
}

.note-text-input:focus {
    outline: none;
    border-color: var(--accent);
}

.note-text-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Tags */
.tag-input {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    min-height: 50px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--accent);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

.tag-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tag-input input {
    flex: 1;
    min-width: 120px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
}

/* Prompt Display */
.prompt-display {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1rem;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}

/* Products toolbar (filters + sort) */
.products-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.products-toolbar .form-select {
    width: auto;
    min-width: 180px;
}

.products-toolbar .sort-label {
    margin-left: auto;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Search */
.search-box {
    margin-bottom: 1rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
}


/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* Error */
.error {
    background-color: rgba(244, 67, 54, 0.1);
    border: 1px solid var(--danger);
    border-radius: 8px;
    padding: 1rem;
    color: var(--danger);
    margin-bottom: 1rem;
}

/* Success */
.success {
    background-color: rgba(76, 175, 80, 0.1);
    border: 1px solid var(--success);
    border-radius: 8px;
    padding: 1rem;
    color: var(--success);
    margin-bottom: 1rem;
}

/* Dialog Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

@keyframes slideDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Rule List Container */
.rule-list-container {
    margin-top: 0.5rem;
}

.rule-list-item {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.rule-list-item input {
    flex: 1;
}

.rule-list-item .btn {
    min-width: 40px;
    padding: 0.5rem;
    flex-shrink: 0;
}

/* Responsive */
@media (min-width: 768px) {
    .container {
        max-width: 768px;
        margin: 0 auto;
    }
    
    .nav-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .user-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* ============================================
   WYSIWYG Prompt Editor Styles
   ============================================ */

.prompt-editor {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    color: var(--text-primary);
}

/* Main section headers (=== HEADER ===) - editable */
.prompt-section-header {
    display: block;
    font-weight: 700;
    color: var(--accent);
    background-color: rgba(74, 144, 226, 0.1);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    margin: 1.5rem 0 1rem 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.prompt-section-header:first-child {
    margin-top: 0;
}

.prompt-section-header-input {
    width: 100%;
    font-weight: 700;
    color: var(--accent);
    background-color: rgba(74, 144, 226, 0.1);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    margin: 1.5rem 0 1rem 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: inherit;
    font-size: inherit;
    transition: border-color 0.2s, background-color 0.2s;
}

.prompt-section-header-input:focus {
    outline: none;
    border-color: var(--accent-hover);
    background-color: rgba(74, 144, 226, 0.15);
}

.prompt-section-header-input:first-child {
    margin-top: 0;
}

/* Sub-section headers (like ZIEL:, WORKFLOW:) - editable */
.prompt-subsection-header {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.25rem 0 0.5rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px dashed var(--border);
}

.prompt-subsection-header-input {
    width: 100%;
    font-weight: 600;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--border);
    padding: 0.5rem 0;
    margin: 1.25rem 0 0.5rem 0;
    font-family: inherit;
    font-size: inherit;
    transition: border-color 0.2s;
}

.prompt-subsection-header-input:focus {
    outline: none;
    border-bottom-color: var(--accent);
    border-bottom-style: solid;
}

/* When inside collapsible header, adjust styling */
.prompt-collapsible-header .prompt-subsection-header-input {
    margin: 0;
    padding: 0.25rem 0;
    border-bottom: none;
    background: transparent;
}

.prompt-collapsible-header .prompt-subsection-header-input:focus {
    border-bottom: 1px solid var(--accent);
    background: rgba(74, 144, 226, 0.05);
}

.prompt-collapsible-header .prompt-section-header-input {
    margin: 0;
    padding: 0.25rem 0.5rem;
    border: 1px solid transparent;
    background: transparent;
}

.prompt-collapsible-header .prompt-section-header-input:focus {
    border-color: var(--accent);
    background: rgba(74, 144, 226, 0.1);
}

/* Tab rule headers (description:, faq:, etc.) - editable */
.prompt-tab-header {
    display: block;
    font-weight: 600;
    color: var(--accent);
    margin: 1rem 0 0.5rem 0;
}

.prompt-tab-header-input {
    width: 100%;
    font-weight: 600;
    color: var(--accent);
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--border);
    padding: 0.25rem 0;
    margin: 1rem 0 0.5rem 0;
    font-family: inherit;
    font-size: inherit;
    transition: border-color 0.2s;
}

.prompt-tab-header-input:focus {
    outline: none;
    border-bottom-color: var(--accent);
    border-bottom-style: solid;
}

/* Lines with label + input */
.prompt-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    margin: 0.35rem 0;
    gap: 0.25rem;
}

.prompt-line-block {
    display: block;
    margin: 0.35rem 0;
}

/* Static label prefix (e.g., "- Sprache: ") */
.prompt-label {
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Editable label prefix input */
.prompt-label-input {
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--border);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: inherit;
    padding: 0.15rem 0.25rem;
    min-width: 100px;
    flex: 0 1 auto;
    transition: border-color 0.2s, color 0.2s;
}

.prompt-label-input:focus {
    outline: none;
    border-bottom-color: var(--accent);
    color: var(--text-primary);
}

/* Inline editable input */
.prompt-input {
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--border);
    color: var(--text-primary);
    font-family: inherit;
    font-size: inherit;
    padding: 0.15rem 0.35rem;
    min-width: 150px;
    flex: 1;
    transition: border-color 0.2s, background-color 0.2s;
}

.prompt-input:focus {
    outline: none;
    border-bottom-color: var(--accent);
    background-color: rgba(74, 144, 226, 0.05);
}

.prompt-input:hover {
    border-bottom-color: var(--text-secondary);
}

/* Smaller inline input for short values */
.prompt-input-small {
    min-width: 80px;
    max-width: 150px;
    flex: 0 1 auto;
}

/* Medium inline input */
.prompt-input-medium {
    min-width: 200px;
    max-width: 400px;
}

/* Number input */
.prompt-input-number {
    min-width: 50px;
    max-width: 80px;
    flex: 0 1 auto;
    text-align: center;
}

/* Textarea for multi-line content */
.prompt-textarea {
    background: rgba(0, 0, 0, 0.15);
    border: 1px dashed var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: inherit;
    padding: 0.5rem;
    width: 100%;
    min-height: 80px;
    resize: both;
    margin: 0.5rem 0;
    transition: border-color 0.2s, background-color 0.2s;
}

.prompt-textarea:focus {
    outline: none;
    border-color: var(--accent);
    background-color: rgba(74, 144, 226, 0.05);
}

/* Rules list container */
.prompt-rules {
    margin: 0.5rem 0;
    padding-left: 0;
}

.prompt-rule-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.25rem 0;
}

.prompt-rule-item::before {
    content: '-';
    color: var(--text-secondary);
    flex-shrink: 0;
}

.prompt-rule-item input {
    flex: 1;
}

.prompt-rule-item .btn-remove {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.prompt-rule-item .btn-remove:hover {
    opacity: 1;
}

.prompt-add-rule {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    margin-top: 0.5rem;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.prompt-add-rule:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Key-Value pairs container */
.prompt-kv-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0.5rem 0;
    padding: 0.5rem;
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    border: 1px solid transparent;
}

.prompt-kv-item:hover {
    border-color: var(--border);
}

.prompt-kv-key {
    flex: 0 0 120px;
    min-width: 100px;
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--border);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.25rem 0.35rem;
}

.prompt-kv-key:focus {
    outline: none;
    border-bottom-color: var(--accent);
}

.prompt-kv-value {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--border);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.25rem 0.35rem;
    resize: both;
    min-height: 1.5rem;
}

.prompt-kv-value:focus {
    outline: none;
    border-bottom-color: var(--accent);
}

.prompt-kv-item .btn-remove {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.prompt-kv-item .btn-remove:hover {
    opacity: 1;
}

.prompt-add-kv {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    margin-top: 0.5rem;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.prompt-add-kv:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Select dropdown styled like input */
.prompt-select {
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--border);
    color: var(--text-primary);
    font-family: inherit;
    font-size: inherit;
    padding: 0.15rem 0.35rem;
    cursor: pointer;
}

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

/* Indented content */
.prompt-indent {
    margin-left: 1.5rem;
}

.prompt-indent-2 {
    margin-left: 3rem;
}

/* Info/hint text */
.prompt-hint {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-style: italic;
    margin: 0.25rem 0;
}

/* Separator line */
.prompt-separator {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* Collapsible sections within prompt editor */
.prompt-collapsible {
    margin: 1rem 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

/* Ensure collapsibles are collapsed by default */
.prompt-collapsible:not(.open) .prompt-collapsible-content {
    display: none !important;
}

.prompt-collapsible-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s;
    gap: 0.5rem;
}

.prompt-collapsible-header:hover {
    background: rgba(0, 0, 0, 0.2);
}

.prompt-collapsible-header::before {
    content: '▶';
    display: inline-block;
    font-size: 0.7rem;
    transition: transform 0.2s;
    color: var(--accent);
    flex-shrink: 0;
}

.prompt-collapsible.open .prompt-collapsible-header::before {
    transform: rotate(90deg);
}

.prompt-collapsible-content {
    display: none;
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}

.prompt-collapsible.open .prompt-collapsible-content {
    display: block;
}

/* Editable inputs inside collapsible headers should not trigger toggle */
.prompt-collapsible-header input,
.prompt-collapsible-header textarea {
    pointer-events: auto;
}

.prompt-collapsible-header input:focus,
.prompt-collapsible-header textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* JSON structure preview */
.prompt-json-preview {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1rem;
    margin: 0.5rem 0;
    white-space: pre-wrap;
    font-size: 0.85rem;
}

/* Product class section */
.prompt-class-section {
    margin: 1rem 0;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.prompt-class-title {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.prompt-tab-label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

/* Readonly display text */
.prompt-readonly {
    color: var(--text-secondary);
    font-style: italic;
}

/* Save status within prompt editor */
.prompt-save-status {
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
    padding: 0.75rem;
    margin: 1rem -1.5rem -1.5rem -1.5rem;
    border-top: 1px solid var(--border);
    border-radius: 0 0 12px 12px;
    text-align: center;
}

/* Responsive adjustments for prompt editor */
@media (max-width: 600px) {
    .prompt-editor {
        padding: 1rem;
        font-size: 0.85rem;
    }
    
    .prompt-line {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .prompt-input,
    .prompt-input-small,
    .prompt-input-medium {
        width: 100%;
        max-width: none;
        min-width: auto;
    }
    
    .prompt-indent {
        margin-left: 1rem;
    }
    
    .prompt-indent-2 {
        margin-left: 2rem;
    }
}
