/* CSS Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: #F6F8FA;
    color: #1F2937;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
}

.hidden {
    display: none !important;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
}

button,
input,
textarea {
    font: inherit;
}

/* Buttons */
.btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 42px;
    font-size: 0.95rem;
}

.btn-primary {
    background-color: #3A8EEF;
    color: white;
    border-color: #3A8EEF;
}

.btn-primary:hover {
    background-color: #2F7ED8;
    border-color: #2F7ED8;
}

.btn-primary:disabled {
    background-color: #A8C7FA;
    border-color: #A8C7FA;
    cursor: not-allowed;
}

.btn-ghost {
    background-color: transparent;
    color: #3A8EEF;
    border-color: #3A8EEF;
}

.btn-ghost:hover {
    background-color: #E8F1FF;
}

.btn-block {
    width: 100%;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #374151;
    font-size: 0.95rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    padding: 0.75rem 0.875rem;
    font-size: 0.95rem;
    background-color: white;
    color: #1F2937;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3A8EEF;
    box-shadow: 0 0 0 3px rgba(58, 142, 239, 0.12);
}

.form-hint {
    font-size: 0.85rem;
    color: #6B7280;
    margin-top: 0.5rem;
    line-height: 1.5;
}

/* Login Screen */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #F6F8FA 0%, #E8F1FF 100%);
}

.auth-card {
    background-color: white;
    border-radius: 16px;
    padding: 3rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
    border: 1px solid #E5E7EB;
}

.auth-logo {
    width: 56px;
    height: 56px;
    margin-bottom: 1.5rem;
}

.auth-logo svg {
    width: 100%;
    height: 100%;
    display: block;
}

.auth-card h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #1F2937;
}

.auth-subtitle {
    color: #6B7280;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* Dashboard */
.dashboard {
    min-height: 100vh;
    background-color: #F6F8FA;
}

.dashboard-header {
    background-color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #E5E7EB;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-brand h1 {
    font-size: 1.5rem;
    color: #1F2937;
}

.header-status {
    width: 10px;
    height: 10px;
    background-color: #10B981;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #6B7280;
    font-size: 0.95rem;
}

.dashboard-main {
    padding: 2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    grid-template-rows: auto auto;
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.panel {
    background-color: white;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid #E5E7EB;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.panel h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: #1F2937;
}

/* New Project Panel */
.panel-new-project {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
}

.chips-input-wrapper {
    position: relative;
}

.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    min-height: 36px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background-color: #E8F1FF;
    color: #1D4ED8;
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.chip button {
    border: none;
    background: none;
    color: #1D4ED8;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.1rem;
}

/* Chat Panel */
.panel-chat {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    min-height: 520px;
}

.chat-conversation {
    flex: 1;
    background-color: #F9FAFB;
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid #E5E7EB;
    overflow-y: auto;
    min-height: 320px;
}

.message {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
}

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

.message.user .message-content {
    background-color: #3A8EEF;
    color: white;
    border-radius: 12px 12px 0 12px;
}

.message.fleet .message-content {
    background-color: white;
    color: #1F2937;
    border-radius: 12px 12px 12px 0;
    border: 1px solid #E5E7EB;
}

.message-content {
    max-width: 75%;
    padding: 0.75rem 1rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-meta {
    font-size: 0.75rem;
    color: #6B7280;
    margin-top: 0.25rem;
}

.empty-state,
.loading-state,
.error-state {
    text-align: center;
    color: #6B7280;
    padding: 2rem;
    border: 1px dashed #D1D5DB;
    border-radius: 12px;
    background-color: #F9FAFB;
}

.chat-form {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.chat-input-wrapper {
    flex: 1;
}

.chat-input-wrapper textarea {
    resize: vertical;
    min-height: 48px;
}

.working-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    color: #3A8EEF;
    font-size: 0.95rem;
}

/* Projects Panel */
.panel-projects {
    grid-column: 1 / 3;
    grid-row: 2 / 3;
}

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

.project-card {
    background-color: #F9FAFB;
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid #E5E7EB;
}

.project-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #1F2937;
}

.project-card p {
    font-size: 0.9rem;
    color: #6B7280;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.project-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #6B7280;
}

.project-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
}

.project-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10B981;
}

.project-status.pending::before {
    background-color: #F59E0B;
}

.project-status.error::before {
    background-color: #EF4444;
}

/* Error Messages */
.error-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background-color: #FEF2F2;
    color: #991B1B;
    border-radius: 8px;
    border: 1px solid #FECACA;
    font-size: 0.9rem;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #E5E7EB;
    border-top-color: #3A8EEF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.dots {
    display: inline-flex;
    gap: 0.15rem;
}

.dots span {
    width: 4px;
    height: 4px;
    background-color: white;
    border-radius: 50%;
    animation: blink 1.4s infinite;
}

.dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes blink {
    0%, 80%, 100% {
        opacity: 0;
    }
    40% {
        opacity: 1;
    }
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .panel-new-project,
    .panel-chat,
    .panel-projects {
        grid-column: 1;
        grid-row: auto;
    }
}

@media (max-width: 768px) {
    .auth-card {
        padding: 2rem;
    }

    .dashboard-header {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-user {
        width: 100%;
        justify-content: space-between;
    }

    .dashboard-main {
        padding: 1rem;
    }

    .chat-form {
        flex-direction: column;
    }

    .message-content {
        max-width: 90%;
    }
}

/* Accessibility: Focus Styles */
button:focus,
input:focus,
textarea:focus,
[tabindex]:focus {
    outline: 2px solid #3A8EEF;
    outline-offset: 2px;
}