/* AutoArchitect - Professional UI Styles */

:root {
    /* Color Palette */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #0ea5e9;
    --accent: #8b5cf6;

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-card: #1e1e3f;

    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-light: rgba(255, 255, 255, 0.05);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-secondary: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
    --gradient-dark: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --gradient-glow: radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Font */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

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

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.version {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.nav-section {
    padding: 0 16px;
    margin-bottom: 24px;
}

.nav-section h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-left: 12px;
}

.nav-btn, .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.nav-btn:hover, .nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

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

.nav-link.website-link:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
}

.nav-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

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

.project-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.project-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.project-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.project-item.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.project-item.active .nav-icon {
    opacity: 1;
}

.project-item.active {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}


/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--gradient-glow), var(--bg-primary);
}

/* Header */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.project-title-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.project-title-container h1 {
    margin: 0;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    opacity: 0.5;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.edit-title-btn {
    opacity: 0.4;
    filter: grayscale(100%);
    transition: all var(--transition-fast);
}

.project-title-container:hover .edit-title-btn,
.edit-title-btn:hover {
    opacity: 1;
    filter: grayscale(0%);
}

/* Edit title input */
.edit-title-input {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    outline: none;
    min-width: 200px;
}

.main-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-status {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

.header-right {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Mobile menu button - hidden by default */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.mobile-menu-btn:hover {
    background: var(--primary);
}

/* Currency Toggle */
.currency-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 2px;
}

.currency-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.currency-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Content Wrapper */
.content-wrapper {
    flex: 1;
    overflow: hidden;
    padding: 24px;
    display: flex;
    flex-direction: row;
    gap: 24px;
    max-height: calc(100vh - 80px);
}

.content-wrapper.vertical {
    flex-direction: column;
}

/* When showing input panel, use vertical layout */
.content-wrapper:has(.input-panel:not([style*="display: none"])) {
    flex-direction: column;
    overflow: auto;
}

/* Panels */
.panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Input panel should be full width */
.input-panel {
    flex: 0 0 auto;
}

/* Chat and Results panels should share space */
.chat-panel,
.results-panel {
    flex: 1 1 50%;
    min-width: 0;
}

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

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-header p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.panel-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.panel-toggle {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
}

.panel-toggle:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.panel-content {
    padding: 24px;
    transition: all var(--transition-base);
    overflow-y: auto;
    flex: 1;
}

.panel-content-collapsible {
    transition: all var(--transition-base);
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.panel.minimized .panel-content,
.panel.minimized .panel-content-collapsible,
.panel.minimized .chat-input-wrapper {
    display: none;
}

.panel.minimized {
    flex: 0 0 auto !important;
}

.panel.minimized .panel-header {
    border-bottom: none;
}

.panel-actions {
    display: flex;
    gap: 8px;
}

/* Input Fields */
.input-group {
    margin-bottom: 20px;
}

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

.input-field {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: all var(--transition-fast);
}

.input-field::placeholder {
    color: var(--text-muted);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.input-field.textarea {
    min-height: 180px;
    resize: vertical;
    line-height: 1.6;
}

.input-field.select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.context-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 1200px) {
    .context-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .context-grid {
        grid-template-columns: 1fr;
    }
}

/* Chat Panel */
.chat-panel {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px);
    min-height: 300px;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 100%;
}

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.assistant {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.user .message-avatar {
    background: var(--gradient-primary);
}

.assistant .message-avatar {
    background: var(--gradient-secondary);
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.6;
}

.user .message-content {
    background: var(--gradient-primary);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.assistant .message-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: var(--radius-sm);
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
}

.chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Results Panel */
.results-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 140px);
    overflow: hidden;
}

.results-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    max-height: 100%;
}

/* Integrated chat in results panel */
.results-chat-wrapper {
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 12px 20px 16px;
}

.results-chat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.results-section {
    margin-bottom: 32px;
}

.results-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}

.results-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    vertical-align: top;
}

.results-card h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 12px;
    margin-top: 0;
    padding-top: 0;
}

.results-card ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.results-card li {
    padding: 8px 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.results-card li:last-child {
    border-bottom: none;
}

.results-card li::before {
    content: "•";
    color: var(--primary);
    margin-right: 10px;
}

.tech-stack-table {
    width: 100%;
    border-collapse: collapse;
}

.tech-stack-table th,
.tech-stack-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.tech-stack-table th {
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.tech-stack-table td {
    color: var(--text-primary);
    font-size: 14px;
}

.diagram-container {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 32px;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    clear: both;
    display: block;
}

.diagram-container h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.mermaid {
    display: block;
    width: 100%;
    min-height: 100px;
    background: rgba(255, 255, 255, 0.02);
    padding: 20px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    overflow-y: visible;
}

.mermaid svg {
    max-width: 100%;
    height: auto !important;
    display: block;
    margin: 0 auto;
}

.cost-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.cost-card {
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
}

.cost-card .amount {
    font-size: 32px;
    font-weight: 700;
    color: white;
}

.cost-card .label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 4px;
}

/* Cost table styling */
.cost-table .subtotal-row {
    background: var(--bg-secondary);
    border-top: 2px solid var(--border-color);
}

.cost-table .contingency-row {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.cost-table .total-row {
    background: var(--gradient-primary);
    color: white;
}

.cost-table .total-row td {
    color: white !important;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 35, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.loading-content {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.loading-spinner {
    width: 64px;
    height: 64px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

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

.loading-content h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.loading-content p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.loading-progress {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 24px;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    width: 0%;
    transition: width 0.5s ease;
}

.loading-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.loading-steps .step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-muted);
    opacity: 0.5;
    transition: all var(--transition-base);
}

.loading-steps .step.active {
    opacity: 1;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--primary);
}

.loading-steps .step.complete {
    opacity: 1;
    color: var(--success);
}

.loading-steps .step.complete::after {
    content: "✓";
    margin-left: auto;
    color: var(--success);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 35, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 40px;
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.modal-fullscreen {
    width: 95vw;
    height: 95vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.modal-body {
    flex: 1;
    overflow: auto;
}

.report-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Responsive */
@media (max-width: 1200px) {
    .content-wrapper {
        flex-direction: column;
        overflow: auto;
        max-height: none;
    }

    .chat-panel,
    .results-panel {
        flex: 0 0 auto;
        max-height: 500px;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        z-index: 100;
        transition: left var(--transition-base);
        width: 280px;
        height: 100vh;
    }

    .sidebar.open {
        left: 0;
    }

    /* Mobile overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .content-wrapper {
        padding: 12px;
        flex-direction: column;
        gap: 16px;
    }

    .chat-panel,
    .results-panel {
        max-height: none;
        min-height: 300px;
    }

    .context-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Mobile header adjustments */
    .main-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .main-header h1 {
        font-size: 16px;
    }

    /* Mobile menu button */
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        color: var(--text-primary);
        font-size: 20px;
        cursor: pointer;
        margin-right: 8px;
    }

    .mobile-menu-btn:hover {
        background: var(--primary);
    }

    /* Currency toggle mobile */
    .currency-toggle {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
    }

    .currency-btn {
        flex: 1;
        justify-content: center;
    }

    /* Header actions mobile */
    .header-actions {
        order: 2;
        gap: 8px;
    }

    .header-actions .btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .header-actions .btn span:first-child {
        margin-right: 4px;
    }

    /* Input panel mobile */
    .input-panel {
        padding: 16px;
    }

    .input-panel h2 {
        font-size: 20px;
    }

    .input-panel .subtitle {
        font-size: 13px;
    }

    .input-group label {
        font-size: 13px;
    }

    .input-field,
    .textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }

    .textarea {
        min-height: 100px;
    }

    /* Generate button mobile */
    .btn-generate {
        width: 100%;
        padding: 16px;
        font-size: 16px;
    }

    /* Results panel mobile */
    .results-panel {
        padding: 16px;
    }

    .results-section h3 {
        font-size: 16px;
        position: static;
        background: none;
        padding: 0;
        margin-bottom: 16px;
    }

    .results-card {
        padding: 16px;
    }

    .results-card h4 {
        font-size: 14px;
    }

    /* Cost cards mobile */
    .cost-summary {
        flex-direction: column;
        gap: 12px;
    }

    .cost-card {
        padding: 20px;
    }

    .cost-card .amount {
        font-size: 28px;
    }

    /* Tech stack table mobile */
    .tech-stack-table {
        font-size: 12px;
    }

    .tech-stack-table th,
    .tech-stack-table td {
        padding: 8px 10px;
    }

    /* Diagrams mobile */
    .diagram-container {
        overflow-x: auto;
        margin: 0 -16px;
        padding: 0 16px;
    }

    .diagram-container .mermaid {
        min-width: 300px;
    }

    /* Chat input mobile */
    .chat-input-container {
        padding: 12px;
    }

    .chat-input {
        font-size: 16px;
        padding: 12px;
    }

    .chat-send-btn {
        width: 44px;
        height: 44px;
    }

    /* Loading screen mobile */
    .loading-overlay h2 {
        font-size: 20px;
    }

    .loading-steps {
        width: 90%;
        max-width: 300px;
    }

    .step {
        padding: 12px 16px;
        font-size: 13px;
    }

    /* Modal mobile */
    .modal-content {
        width: 95%;
        max-width: none;
        max-height: 90vh;
        margin: 5vh auto;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    /* Project list mobile */
    .project-item {
        padding: 12px;
    }

    .project-item .project-name {
        font-size: 13px;
    }

    /* Nav links mobile */
    .nav-link {
        padding: 12px 16px;
        font-size: 14px;
    }

    /* Toast mobile */
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
    .content-wrapper {
        padding: 8px;
    }

    .input-panel,
    .results-panel,
    .chat-panel {
        padding: 12px;
        border-radius: var(--radius-md);
    }

    .input-panel h2 {
        font-size: 18px;
    }

    .context-grid {
        gap: 8px;
    }

    .input-group {
        margin-bottom: 12px;
    }

    .btn-generate {
        padding: 14px;
        font-size: 15px;
    }

    .results-section {
        margin-bottom: 20px;
    }

    .cost-card .amount {
        font-size: 24px;
    }

    /* Hide some table columns on very small screens */
    .tech-stack-table th:nth-child(3),
    .tech-stack-table td:nth-child(3) {
        display: none;
    }

    .main-header h1 {
        font-size: 14px;
    }

    .header-actions .btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* Tablet landscape */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }

    .content-wrapper {
        padding: 16px;
        gap: 16px;
    }

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

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    .nav-link,
    .project-item,
    .currency-btn {
        min-height: 44px;
    }

    .input-field,
    .textarea,
    .select {
        min-height: 48px;
    }

    /* Remove hover states on touch */
    .btn:hover,
    .nav-link:hover,
    .project-item:hover {
        transform: none;
    }

    /* Better scrolling */
    .results-panel,
    .chat-messages,
    .modal-body {
        -webkit-overflow-scrolling: touch;
    }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
    .loading-overlay {
        padding: 20px;
    }

    .loading-steps {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .step {
        flex: 0 0 auto;
    }

    .modal-content {
        max-height: 95vh;
    }
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
    .app-container {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .sidebar {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .chat-input-container {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .toast {
        bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: rgba(255, 255, 255, 0.3);
    }

    .btn {
        border-width: 2px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    opacity: 0;
    transform: translateY(20px);
    transition: all var(--transition-base);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    border-color: var(--success);
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-error {
    border-color: var(--error);
}

.toast-error .toast-icon {
    color: var(--error);
}

.toast-info {
    border-color: var(--info);
}

.toast-info .toast-icon {
    color: var(--info);
}

.toast-icon {
    font-size: 18px;
    font-weight: bold;
}

.toast-message {
    font-size: 14px;
    color: var(--text-primary);
}
