/* AI App Builder - Dark Mode Mobile UI */
:root {
    --primary: #10A37F;
    --primary-dark: #0D8C6B;
    --primary-glow: rgba(16, 163, 127, 0.4);
    --bg-primary: #0D0D0D;
    --bg-secondary: #1A1A1A;
    --bg-tertiary: #252525;
    --bg-input: #2D2D2D;
    --text-primary: #FFFFFF;
    --text-secondary: #A0A0A0;
    --text-tertiary: #6B6B6B;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(16, 163, 127, 0.3);
    --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px var(--primary-glow);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --nav-height: 72px;
    --header-height: 56px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 430px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    position: relative;
    background: var(--bg-primary);
    overflow: hidden;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.screen::-webkit-scrollbar {
    display: none;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

/* Home Screen */
#home-screen {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: calc(24px + var(--safe-top)) 20px calc(100px + var(--safe-bottom));
}

.home-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding-top: 40px;
}

/* Logo */
.logo-section {
    display: flex;
    justify-content: center;
}

.logo-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 8px 32px var(--primary-glow);
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 8px 32px var(--primary-glow); }
    50% { box-shadow: 0 12px 48px var(--primary-glow), 0 0 60px rgba(16, 163, 127, 0.2); }
}

.logo-icon svg {
    width: 32px;
    height: 32px;
}

/* Headline */
.headline {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    color: var(--text-primary);
    max-width: 320px;
    letter-spacing: -0.02em;
}

/* Input Section */
.input-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

.idea-input {
    width: 100%;
    min-height: 120px;
    padding: 16px 52px 16px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
}

.idea-input::placeholder {
    color: var(--text-tertiary);
}

.idea-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.15);
}

.mic-button {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mic-button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.mic-button:active {
    transform: scale(0.95);
}

/* Chips */
.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.chip {
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chip:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: rgba(16, 163, 127, 0.08);
}

.chip:active {
    transform: scale(0.96);
}

/* CTA Section */
.cta-section {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-bottom));
    left: 0;
    right: 0;
    padding: 16px 20px;
    background: linear-gradient(to top, var(--bg-primary) 0%, transparent 100%);
    z-index: 100;
    max-width: 430px;
    margin: 0 auto;
}

.generate-btn {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(16, 163, 127, 0.4), var(--shadow-glow);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.generate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.generate-btn:hover::before {
    left: 100%;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 32px rgba(16, 163, 127, 0.5), 0 0 60px rgba(16, 163, 127, 0.3);
}

.generate-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Screen Headers */
.screen-header {
    position: sticky;
    top: 0;
    padding: calc(16px + var(--safe-top)) 20px 16px;
    background: rgba(13, 13, 13, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 50;
    border-bottom: 1px solid var(--border-subtle);
}

.screen-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Projects Screen */
.projects-list {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.project-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.project-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-tertiary);
}

.project-card:active {
    transform: scale(0.98);
}

.project-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.project-info {
    flex: 1;
    min-width: 0;
}

.project-info h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-info p {
    font-size: 13px;
    color: var(--text-tertiary);
}

.project-status {
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.project-status.active {
    background: rgba(16, 163, 127, 0.15);
    color: var(--primary);
}

/* History Screen */
.history-list {
    padding: 8px 20px;
}

.history-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.history-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.history-content {
    flex: 1;
    min-width: 0;
}

.history-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 6px;
    word-wrap: break-word;
}

.history-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Settings Screen */
.settings-list {
    padding: 16px 20px;
}

.settings-group {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid var(--border-subtle);
}

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

.settings-item:hover {
    background: var(--bg-tertiary);
}

.settings-item:active {
    background: rgba(16, 163, 127, 0.08);
}

.settings-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.settings-label {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-arrow {
    color: var(--text-tertiary);
}

.settings-footer {
    text-align: center;
    padding: 24px;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* Chat Screen */
#chat-screen {
    padding: 0;
    padding-bottom: calc(80px + var(--safe-bottom));
    background: var(--bg-primary);
}

.chat-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(12px + var(--safe-top)) 16px 12px;
    background: rgba(13, 13, 13, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 50;
}

.back-btn, .icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.back-btn:hover, .icon-btn:hover {
    background: var(--bg-secondary);
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-messages {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-content {
    background: var(--primary);
    color: white;
}

.message-content {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 4px;
}

/* Chat Input */
.chat-input-section {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px calc(12px + var(--safe-bottom));
    background: rgba(13, 13, 13, 0.98);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
    z-index: 100;
    max-width: 430px;
    margin: 0 auto;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 4px 4px 4px 16px;
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    outline: none;
    padding: 10px 0;
}

.chat-input::placeholder {
    color: var(--text-tertiary);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(13, 13, 13, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    max-width: 430px;
    margin: 0 auto;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    stroke-width: 2;
    transition: all 0.2s ease;
}

.nav-item span {
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active svg {
    stroke-width: 2.5;
}

.nav-item:hover {
    color: var(--text-secondary);
}

/* Hide nav on chat screen */
#chat-screen.active ~ .bottom-nav {
    display: none;
}

/* Responsive */
@media (min-width: 431px) {
    .app-container {
        border-left: 1px solid var(--border-subtle);
        border-right: 1px solid var(--border-subtle);
    }
}

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

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

/* Focus states for accessibility */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: rgba(16, 163, 127, 0.3);
    color: var(--text-primary);
}