/* ANTEROS Mobile - styles
 * Dark theme, mobile-first, reprend l'identite visuelle d'ANTEROS Desktop
 */

:root {
    --bg:          #0a0e17;
    --bg-elev:    #131825;
    --bg-elev-2: #1b2130;
    --border:     #2a3344;
    --text:       #e8ecf3;
    --text-muted: #8b93a7;
    --accent:     #4a7fc7;
    --accent-hover: #5a8fd7;
    --success:    #00b894;
    --warning:    #fdcb6e;
    --danger:     #ff6b6b;
    --nav-h:      64px;
    --topbar-h:   52px;
    --radius:     12px;
    --shadow:     0 4px 20px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
    touch-action: manipulation;
}
body {
    padding-bottom: env(safe-area-inset-bottom);
    padding-top: env(safe-area-inset-top);
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); margin: 4px 0 12px; }
.mono { font-family: "SF Mono", Consolas, Monaco, monospace; font-size: 13px; }
.center { text-align: center; }
.error-msg { color: var(--danger); min-height: 1.2em; }

/* ============ Setup screen ============ */
.screen-setup {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at top, var(--bg-elev) 0%, var(--bg) 70%);
}
.setup-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-elev);
    padding: 32px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.setup-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--accent), var(--success));
    border-radius: 50%;
    font-size: 40px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}
.setup-card h1 {
    text-align: center;
    margin: 0 0 8px;
    font-weight: 600;
}
.setup-intro {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 24px;
    font-size: 14px;
}
.setup-intro code {
    background: var(--bg-elev-2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}
#setup-form label {
    display: block;
    margin-bottom: 14px;
}
#setup-form label span {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 13px;
}
#setup-form input[type=text] {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    font-family: "SF Mono", monospace;
}
#setup-form input[type=text]:focus {
    outline: none;
    border-color: var(--accent);
}

/* ============ Main app ============ */
.screen-app {
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-top: var(--topbar-h);
}

/* ============ Topbar ============ */
.topbar {
    position: fixed;
    top: env(safe-area-inset-top);
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
    z-index: 10;
    backdrop-filter: blur(8px);
}
.topbar-title {
    font-weight: 700;
    letter-spacing: 0.5px;
    flex: 1;
}
.presence-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 6px currentColor;
}
.presence-dot.online {
    background: var(--success);
    color: var(--success);
}
.presence-text {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============ Cards + Tabs ============ */
.tab-content {
    padding: 16px;
    animation: fadeIn 0.2s ease-out;
}
.tab-title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 600;
}
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.card h2, .card h3 {
    margin: 0 0 8px;
}
.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}
.status-item {
    background: var(--bg);
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.status-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    margin-top: 4px;
}
.status-value.good  { color: var(--success); }
.status-value.bad   { color: var(--danger); }
.status-value.warn  { color: var(--warning); }

.kv {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.kv:last-child { border-bottom: none; }
.kv > :first-child { color: var(--text-muted); font-size: 13px; }

/* ============ Projects list ============ */
.projects-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}
.project-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s;
}
.project-card:active {
    transform: scale(0.98);
    background: var(--bg-elev-2);
}
.project-card-body {
    flex: 1;
    min-width: 0;
}
.project-card-title {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
}
.project-card-desc {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.project-card-chat-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 28px;
    cursor: pointer;
    padding: 4px 8px;
    align-self: center;
}
.project-card-chat-btn:active {
    transform: scale(0.9);
}
.project-card-category {
    display: inline-block;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-elev-2);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
}

/* ============ Bottom nav ============ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 20;
}
.nav-item {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 2px;
    cursor: pointer;
    transition: color 0.15s;
    min-width: 0;
}
.nav-item.active {
    color: var(--accent);
}
.nav-icon {
    font-size: 20px;
    line-height: 1;
}
.nav-label {
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Formulaire "Nouveau projet" */
.field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#new-project-form input[type=text],
#new-project-form select,
#new-project-form textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
}
#new-project-form textarea {
    resize: vertical;
    min-height: 90px;
}
#new-project-form input:focus,
#new-project-form select:focus,
#new-project-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}
#new-project-form .chat-input-row {
    align-items: flex-start;
}

/* ============ Buttons ============ */
button {
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
}
button[type=submit],
.primary {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.15s, transform 0.1s;
}
button[type=submit]:active,
.primary:active {
    background: var(--accent-hover);
    transform: scale(0.98);
}
.secondary {
    width: 100%;
    padding: 12px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
}
.danger {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 8px;
}

/* ============ Action sheet (long-press menu) ============ */
.action-sheet {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: flex-end;
    pointer-events: none;
}
.action-sheet.visible { pointer-events: auto; }
.action-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s;
}
.action-sheet.visible .action-sheet-backdrop { opacity: 1; }
.action-sheet-content {
    position: relative;
    width: 100%;
    background: var(--bg-elev);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(.4, 0, .2, 1);
    max-height: 70vh;
    overflow-y: auto;
}
.action-sheet.visible .action-sheet-content { transform: translateY(0); }
.action-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.action-sheet-header span {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.action-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 8px;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    border-radius: 8px;
    text-align: left;
}
.action-item:active {
    background: var(--bg-elev-2);
}
.action-icon {
    font-size: 22px;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}
.action-label {
    flex: 1;
}

/* ============ Chat panel ============ */
.chat-panel {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(.4, 0, .2, 1);
}
.chat-panel.visible {
    transform: translateY(0);
}
.chat-panel.hidden {
    display: none;
}
.chat-header {
    height: var(--topbar-h);
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 8px;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
}
.chat-title {
    flex: 1;
    margin: 0 8px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.chat-title #chat-project-name {
    font-weight: 600;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-family: "SF Mono", monospace;
}
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 24px;
    padding: 8px 12px;
    cursor: pointer;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.4;
}
.msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}
.msg.assistant {
    align-self: flex-start;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    font-family: "SF Mono", Consolas, monospace;
    font-size: 13px;
}
.msg.system {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
    text-align: center;
    max-width: 100%;
}
.msg.error {
    align-self: flex-start;
    background: rgba(255,107,107,0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
    font-size: 13px;
}
.msg.streaming::after {
    content: "\0025AC";
    color: var(--accent);
    animation: blink 1s infinite;
    margin-left: 4px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.chat-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-elev);
    padding: 8px 12px 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
/* Chips commandes rapides */
.chat-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.chat-chips::-webkit-scrollbar { display: none; }
.chip {
    flex-shrink: 0;
    padding: 6px 12px;
    background: var(--bg-elev-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.chip:active {
    background: var(--accent);
    color: white;
    transform: scale(0.95);
}

.chat-mode-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-muted);
}
.chat-mode-selector label {
    display: flex;
    align-items: center;
    gap: 4px;
}
.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
#chat-input {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
}
#chat-input:focus {
    outline: none;
    border-color: var(--accent);
}
.mic-btn, .send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.mic-btn {
    background: var(--bg-elev-2);
    color: var(--text-muted);
    transition: all 0.2s;
}
.mic-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.mic-btn:not(:disabled):active {
    transform: scale(0.9);
}
.mic-btn.listening {
    background: var(--danger);
    color: white;
    animation: pulse-mic 1.2s infinite;
}
@keyframes pulse-mic {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.6);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(255, 107, 107, 0);
    }
}

.send-btn {
    background: var(--accent);
    color: white;
}
.send-btn:active {
    transform: scale(0.9);
}

/* Toggle switches dans les reglages */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.toggle-row:last-of-type {
    border-bottom: none;
}
.toggle-row > span {
    flex: 1;
    padding-right: 12px;
    font-size: 14px;
}
.toggle-row input[type=checkbox] {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 24px;
    background: var(--bg-elev-2);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-row input[type=checkbox]::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-row input[type=checkbox]:checked {
    background: var(--accent);
}
.toggle-row input[type=checkbox]:checked::before {
    transform: translateX(20px);
}

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