/* Sonja PWA — Dark Theme, Mobile-first */

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1f2940;
    --bg-input: #0f1923;
    --text-primary: #e4e4e4;
    --text-secondary: #8a8fa8;
    --text-muted: #5a5f78;
    --accent: #e94560;
    --accent-soft: #3a1f5e;
    --border: #2a2a4a;
    --success: #4ecca3;
    --warning: #ffd369;
    --error: #e94560;
    --nav-height: 60px;
    --header-height: 50px;
    --radius: 12px;
    --radius-sm: 8px;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Header */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

#header-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
}

#header-status {
    font-size: 11px;
    color: var(--text-muted);
}

/* Main Content */
#app-main {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: var(--nav-height);
    overflow: hidden;
}

.view {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
}

.view[hidden] {
    display: none !important;
}

/* Bottom Navigation */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
    padding: 6px 12px;
    transition: color 0.2s;
}

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

.nav-item svg {
    width: 22px;
    height: 22px;
}

/* More Menu */
#more-menu {
    position: fixed;
    inset: 0;
    z-index: 200;
}

#more-menu[hidden] {
    display: none;
}

.more-menu-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.more-menu-panel {
    position: absolute;
    bottom: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 8px 0;
}

.more-item {
    display: block;
    padding: 14px 20px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 15px;
}

.more-item:active {
    background: var(--bg-card);
}

/* Chat */
#view-chat {
    display: flex;
    flex-direction: column;
    padding: 0;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.msg-user {
    align-self: flex-end;
    background: var(--accent-soft);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.msg-assistant {
    align-self: flex-start;
    background: var(--bg-card);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.msg-provider {
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 1px 6px;
    border-radius: 4px;
}

.msg-tts-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
}

.msg-tts-btn:hover {
    color: var(--accent);
}

#chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

#chat-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 15px;
    outline: none;
}

#chat-input:focus {
    border-color: var(--accent);
}

#chat-input::placeholder {
    color: var(--text-muted);
}

#chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#chat-send:active {
    opacity: 0.8;
}

#chat-mic {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

#chat-mic:hover { color: var(--text-primary); }

#chat-mic.recording {
    background: var(--error);
    color: white;
    border-color: var(--error);
    animation: mic-pulse 1s infinite;
}

@keyframes mic-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* Typing Indicator */
.typing-indicator {
    align-self: flex-start;
    padding: 12px 18px;
    background: var(--bg-card);
    border-radius: var(--radius);
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Tabs */
.tab {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

[id$="-tabs"] {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
}

.card-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.card-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Email expandable */
.email-card { cursor: pointer; transition: background 0.15s; }
.email-card:hover { background: rgba(255,255,255,0.05); }
.email-card.expanded { border-left: 3px solid var(--primary); }

.email-content {
    margin-top: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius-sm);
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
    color: var(--text-secondary);
}

.email-spam-bar {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

.spam-subject-input {
    flex: 1;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 12px;
}

.btn-spam {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--error);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-spam:hover { opacity: 0.85; }
.btn-spam:disabled { opacity: 0.5; cursor: default; }

.email-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.attachment-link {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(78,204,163,0.15);
    border: 1px solid rgba(78,204,163,0.3);
    border-radius: var(--radius-sm);
    color: var(--success);
    font-size: 12px;
    text-decoration: none;
}

.attachment-link:hover { background: rgba(78,204,163,0.25); }

/* Voice Screen */
#voice-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
    padding-top: 40px;
    gap: 24px;
}

#voice-status {
    font-size: 16px;
    color: var(--text-secondary);
    text-align: center;
}

#voice-btn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

#voice-btn:hover { border-color: var(--accent); color: var(--text-primary); }

#voice-btn.voice-recording {
    background: var(--error);
    border-color: var(--error);
    color: white;
    animation: voice-pulse 1.2s infinite;
}

#voice-btn.voice-processing {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    animation: voice-spin 1.5s linear infinite;
}

@keyframes voice-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(233,69,96,0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(233,69,96,0); }
}

@keyframes voice-spin {
    0% { box-shadow: 0 0 0 0 rgba(233,69,96,0.3); }
    50% { box-shadow: 0 0 0 10px rgba(233,69,96,0); }
    100% { box-shadow: 0 0 0 0 rgba(233,69,96,0.3); }
}

#voice-upload-bar {
    display: flex;
    justify-content: center;
}

#voice-upload-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

#voice-upload-label:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

#voice-transcript {
    width: 100%;
    max-height: calc(100vh - 340px);
    overflow-y: auto;
    padding: 0 12px;
}

.voice-msg {
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.4;
}

.voice-msg-du {
    background: rgba(233,69,96,0.1);
    border-left: 3px solid var(--accent);
}

.voice-msg-sonja {
    background: rgba(78,204,163,0.1);
    border-left: 3px solid var(--success);
}

.voice-msg-label {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    margin-right: 8px;
    color: var(--text-muted);
}

.voice-msg-text {
    color: var(--text-primary);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: rgba(78,204,163,0.2); color: var(--success); }
.badge-warning { background: rgba(255,211,105,0.2); color: var(--warning); }
.badge-error { background: rgba(233,69,96,0.2); color: var(--error); }

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:active { opacity: 0.7; }

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

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

/* Settings */
.settings-group {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 12px;
}

.settings-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.settings-group h3 {
    font-size: 15px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.settings-group input[type="password"],
.settings-group input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 8px;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 24px;
    cursor: pointer;
    transition: 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Search bar */
#medien-search-bar {
    margin-bottom: 12px;
}

#medien-search {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
}

#medien-search:focus {
    border-color: var(--accent);
}

/* Fotos Grid */
#fotos-search-bar {
    margin-bottom: 12px;
}

#fotos-search {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
}

#fotos-search:focus {
    border-color: var(--accent);
}

#fotos-stats {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding: 0 4px;
}

#fotos-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.foto-thumb {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
}

.foto-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.foto-thumb:active img {
    transform: scale(1.05);
}

.foto-thumb-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2px 4px;
    background: rgba(0,0,0,0.6);
    font-size: 9px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Lightbox */
#fotos-lightbox {
    position: fixed;
    inset: 0;
    z-index: 300;
}

#fotos-lightbox[hidden] {
    display: none;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.9);
}

.lightbox-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

#lightbox-img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

#lightbox-info {
    margin-top: 12px;
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 90%;
}

#lightbox-close {
    margin-top: 12px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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