/* ===================================
   Notes Sync - PWA Styles
   Visual estilo VS Code + Notas iPhone
   =================================== */

:root {
    /* Cores principais - Dark Theme estilo VS Code */
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --bg-tertiary: #2d2d30;
    --bg-hover: #3c3c3c;
    --bg-active: #094771;

    /* Texto */
    --text-primary: #cccccc;
    --text-secondary: #858585;
    --text-muted: #6e6e6e;

    /* Accent */
    --accent: #0078d4;
    --accent-hover: #1a8cff;
    --success: #4ec9b0;
    --warning: #dcdcaa;
    --error: #f14c4c;

    /* Markdown colors */
    --md-heading: #569cd6;
    --md-bold: #dcdcaa;
    --md-italic: #ce9178;
    --md-code: #d7ba7d;
    --md-link: #4ec9b0;
    --md-checkbox: #0078d4;

    /* Spacing */
    --header-height: 52px;
    --tabs-height: 44px;
    --footer-height: 56px;

    /* Misc */
    --border-radius: 8px;
    --transition: 0.2s ease;
}

/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* ===================================
   Header
   =================================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
    flex-shrink: 0;
}

/* Header Left */
.header-left {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    margin-right: 8px;
}

/* Status Dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    /* Offline/Desconhecido */
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}

.status-dot.saved {
    background: #4ec9b0;
    box-shadow: 0 0 4px rgba(78, 201, 176, 0.4);
}

.status-dot.unsaved {
    background: #dcdcaa;
}

.status-dot.syncing {
    background: #0078d4;
    animation: pulse 1s infinite;
}

/* File Select */
.file-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 4px;
}

.file-select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    width: 100%;
    cursor: pointer;
    padding-right: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-select:focus {
    outline: none;
}

.file-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.select-arrow {
    position: absolute;
    right: 6px;
    width: 14px;
    height: 14px;
    pointer-events: none;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Reduzido gap */
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.icon-btn.active {
    background: var(--md-link);
    color: var(--bg-primary);
}

.icon-btn.active {
    background: var(--md-link);
    /* Cor de destaque para toggle ativo */
    color: var(--bg-primary);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

/* Header Buttons Específicos */
.save-btn-header.unsaved {
    color: var(--warning) !important;
    animation: pulse-save 2s infinite;
}

@keyframes pulse-save {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

/* ===================================
   Tabs
   =================================== */
/* ===================================
   Tabs
   =================================== */
.tabs-container {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    /* Garante largura */
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.tabs {
    display: flex;
    flex-wrap: nowrap;
    /* IMPORTANTE: Impede quebra de linha */
    height: var(--tabs-height);
    padding: 0 8px;
    gap: 4px;
    min-width: 100%;
    /* Garante que o container tenha pelo menos a largura da tela */
    width: max-content;
    /* Permite crescer */
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    height: 100%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    flex-shrink: 0;
    /* Impede encolhimento */
}

.tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tab.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent);
}

.tab-icon {
    font-size: 1rem;
}

.tab-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===================================
   Empty State
   =================================== */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ===================================
   Editor (Raw)
   =================================== */
.editor-container {
    flex: 1;
    /* Ocupa todo espaço restante vertical */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 12px;
    /* Reduzido padding para aproveitar espaço */
    position: relative;
    height: 100%;
}

.editor-container.hidden {
    display: none;
}

.editor {
    flex: 1;
    width: 100%;
    height: 100%;
    /* Garante altura total */
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    resize: none;
    padding: 0;
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
    outline: none;
    -webkit-font-smoothing: antialiased;
    white-space: pre;
    /* Garante quebras de linha corretas */
}

/* ===================================
   Footer (Removed)
   =================================== */

/* ===================================
   Utilities
   =================================== */
.hidden {
    display: none !important;
}

/* ===================================
   Safe Areas (iPhone)
   =================================== */
@supports (padding-top: env(safe-area-inset-top)) {
    .header {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }
}

/* ===================================
   Animations
   =================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.editor-container {
    animation: fadeIn 0.3s ease;
}