/* ==========================================
   Bosnian Syntax Parser - Styles
   Modern, dark theme with glassmorphism
   ========================================== */

:root {
    /* Colors */
    --bg-dark: #0a0a1a;
    --bg-darker: #050510;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --success: #10b981;
    --danger: #ef4444;

    /* Phrase category colors */
    --color-k: #f59e0b;
    --color-gf: #10b981;
    --color-if: #3b82f6;
    --color-pridf: #ec4899;
    --color-prilf: #8b5cf6;
    --color-prijf: #14b8a6;
    --color-df: #f97316;
    --color-cf: #06b6d4;
    --color-word: #64748b;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 40%);
    z-index: -1;
}

/* Glass Panel Effect */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 1fr 280px;
    grid-template-rows: auto 1fr;
    gap: var(--space-lg);
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--space-lg);
    min-height: 100vh;
}

.header {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-lg) 0;
    position: relative;
}

.settings-btn {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-md);
}

.header-buttons {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-md);
    display: flex;
    gap: var(--space-sm);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-xs);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Input Section */
.input-section {
    position: relative;
}

.input-group {
    margin-bottom: var(--space-md);
}

.input-group label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

textarea,
.form-input,
select {
    width: 100%;
    padding: var(--space-md);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus,
.form-input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Buttons */
.button-group {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #0d9568;
    transform: translateY(-2px);
}

.btn-icon-only {
    padding: var(--space-sm);
    min-width: 36px;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-icon {
    font-size: 1.1em;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    color: var(--text-secondary);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none !important;
}

/* Tree Section */
.tree-section {
    flex: 1;
    min-height: 400px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.tree-controls {
    display: flex;
    gap: var(--space-xs);
}

#tree-container {
    width: 100%;
    height: 500px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

#tree-svg {
    width: 100%;
    height: 100%;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

/* Tree Node Styles */
.node circle {
    stroke-width: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.node circle:hover {
    stroke-width: 4px;
    filter: brightness(1.2);
}

.node text {
    font-size: 12px;
    fill: var(--text-primary);
    text-anchor: middle;
}

.node-label {
    font-weight: 600;
}

.node-text {
    font-size: 10px;
    fill: var(--text-secondary);
}

.link {
    fill: none;
    stroke: var(--glass-border);
    stroke-width: 1.5px;
}

/* Correction Section */
.correction-section {
    border: 1px solid var(--accent-primary);
}

.correction-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--space-md);
}

.correction-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.edit-form {
    background: rgba(0, 0, 0, 0.2);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
}

.edit-form h3 {
    font-size: 1rem;
    margin-bottom: var(--space-md);
}

.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-xs);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.hint {
    display: block;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.model-select-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Legend */
.legend-section h3 {
    font-size: 1rem;
    margin-bottom: var(--space-md);
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-sm);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

/* History Sidebar */
.history-sidebar {
    height: fit-content;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    position: sticky;
    top: var(--space-lg);
}

.history-sidebar h3 {
    margin-bottom: var(--space-md);
    font-size: 1rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.history-item {
    padding: var(--space-sm);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background: rgba(99, 102, 241, 0.2);
}

.empty-history {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    padding: var(--space-lg);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    width: 100%;
    max-width: 500px;
    background: #0f0f23;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    padding: 0;
}

.modal-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    margin: 0;
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
}

/* Responsive */
@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .history-sidebar {
        position: static;
        max-height: none;
    }
}

@media (max-width: 600px) {
    .header h1 {
        font-size: 1.75rem;
    }

    .legend-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Chatbot Styles */
.chat-modal-content {
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.chat-body {
    display: flex;
    flex-direction: column;
    height: 400px;
    padding: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.chat-message {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    max-width: 85%;
    line-height: 1.5;
}

.chat-message.bot {
    background: rgba(99, 102, 241, 0.2);
    align-self: flex-start;
}

.chat-message.user {
    background: var(--accent-gradient);
    color: white;
    align-self: flex-end;
}

.chat-message.loading {
    background: rgba(255, 255, 255, 0.1);
    font-style: italic;
    color: var(--text-secondary);
}

.chat-input-area {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-top: 1px solid var(--glass-border);
}

.chat-input-area textarea {
    flex: 1;
    resize: none;
}

.chat-input-area .btn {
    align-self: flex-end;
}