/* ===============================================
   Trainable ChatBot Builder - Styles
   =============================================== */

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

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-color: #1f2937;
    --light-color: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f9fafb;
    color: var(--dark-color);
    line-height: 1.6;
}

/* ===============================================
   Layout
   =============================================== */

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 2rem 1rem;
    box-shadow: var(--shadow-lg);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.header p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.main-content {
    display: flex;
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    gap: 2rem;
    padding: 2rem 1rem;
}

/* ===============================================
   Sidebar
   =============================================== */

.sidebar {
    width: 250px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    background: white;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.nav-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.sidebar-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    background: white;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    font-size: 0.9rem;
    color: #6b7280;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* ===============================================
   Content Area
   =============================================== */

.content {
    flex: 1;
    background: white;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    padding: 2rem;
    box-shadow: var(--shadow);
}

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

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

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

/* ===============================================
   Builder Section
   =============================================== */

.builder-header,
.test-header,
.export-header,
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.builder-header h2,
.test-header h2,
.export-header h2,
.settings-header h2 {
    font-size: 1.5rem;
    color: var(--dark-color);
}

.intents-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.intent-card {
    padding: 1.5rem;
    background: var(--light-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    transition: all 0.3s;
}

.intent-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.intent-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.intent-card-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--dark-color);
}

.intent-card-actions {
    display: flex;
    gap: 0.5rem;
}

.intent-card-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.intent-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.intent-field-label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #6b7280;
}

.intent-field-content {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    font-size: 0.85rem;
    color: #6b7280;
}

.empty-state {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    color: #9ca3af;
    font-size: 1.1rem;
}

/* ===============================================
   Chat Section
   =============================================== */

.chat-container {
    display: flex;
    flex-direction: column;
    height: 500px;
    background: var(--light-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    animation: slideIn 0.3s;
}

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

.user-message {
    justify-content: flex-end;
}

.user-message p {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    max-width: 70%;
    word-wrap: break-word;
}

.bot-message p {
    background: white;
    color: var(--dark-color);
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    max-width: 70%;
    border: 1px solid var(--border-color);
    word-wrap: break-word;
}

.chat-input-group {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--border-color);
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.chat-input:disabled {
    background: var(--light-color);
    cursor: not-allowed;
}

/* ===============================================
   Export Section
   =============================================== */

.export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.export-card {
    padding: 1.5rem;
    background: var(--light-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    text-align: center;
}

.export-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.export-card p {
    color: #6b7280;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.stats-container {
    margin-top: 2rem;
}

.stats-container h3 {
    margin-bottom: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-card {
    padding: 1rem;
    background: var(--light-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    text-align: center;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-card-label {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 0.5rem;
}

/* ===============================================
   Settings Section
   =============================================== */

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-label {
    font-weight: bold;
    color: var(--dark-color);
}

.input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    font-family: inherit;
}

.input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.slider {
    width: 100%;
    cursor: pointer;
}

/* ===============================================
   Buttons
   =============================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

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

.btn-success:hover:not(:disabled) {
    background: #059669;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-secondary {
    background: var(--light-color);
    color: var(--dark-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* ===============================================
   Forms & Modals
   =============================================== */

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: var(--dark-color);
}

.form-group textarea,
.form-group input {
    width: 100%;
}

.form-group small {
    display: block;
    margin-top: 0.5rem;
    color: #6b7280;
    font-size: 0.85rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.modal {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-center .modal-content {
    max-width: 300px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.3s;
}

.close-btn:hover {
    color: var(--dark-color);
}

.modal-content > form,
.modal-content > div:not(.modal-header) {
    padding: 1.5rem;
}

.training-content {
    padding: 2rem;
    text-align: center;
}

.training-content h2 {
    margin-bottom: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--light-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s;
}

/* ===============================================
   Alert
   =============================================== */

.alert {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    background: var(--success-color);
    color: white;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s;
    z-index: 2000;
}

.alert.error {
    background: var(--danger-color);
}

.alert.warning {
    background: var(--warning-color);
}

.alert.info {
    background: var(--primary-color);
}

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

/* ===============================================
   Responsive
   =============================================== */

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        padding: 1rem;
    }

    .sidebar {
        width: 100%;
    }

    .nav-menu {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }

    .builder-header,
    .test-header,
    .export-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .builder-header .btn,
    .test-header .btn,
    .export-header .btn {
        width: 100%;
    }

    .intent-card-content {
        grid-template-columns: 1fr;
    }

    .export-options {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .user-message p,
    .bot-message p {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .nav-menu {
        grid-template-columns: repeat(2, 1fr);
    }

    .sidebar-stats {
        flex-direction: row;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }
}
