:root {
    --primary: #37352f;
    --primary-hover: #2f2f2f;
    --secondary: #f7f7f5;
    --bg-color: #ffffff;
    --surface-color: #ffffff;
    --text-primary: #37352f;
    --text-secondary: #787774;
    --border-color: rgba(55, 53, 47, 0.16);
    --border-color-hover: rgba(55, 53, 47, 0.3);
    
    --input-bg: rgba(242, 241, 238, 0.6);
    --hover-bg: rgba(55, 53, 47, 0.08);
    --btn-secondary-bg: white;
    --btn-primary-text: white;
    --shadow-color: rgba(15, 15, 15, 0.1);
    
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-full: 50%;
    
    --font-main: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
    --primary: #ffffff;
    --primary-hover: #e0e0e0;
    --secondary: #202020;
    --bg-color: #191919;
    --surface-color: #252525;
    --text-primary: #f2f2f2;
    --text-secondary: #9e9e9e;
    --border-color: rgba(255, 255, 255, 0.12);
    --border-color-hover: rgba(255, 255, 255, 0.25);
    
    --input-bg: rgba(255, 255, 255, 0.05);
    --hover-bg: rgba(255, 255, 255, 0.08);
    --btn-secondary-bg: #2b2b2b;
    --btn-primary-text: #191919;
    --shadow-color: rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary: #ffffff;
        --primary-hover: #e0e0e0;
        --secondary: #202020;
        --bg-color: #191919;
        --surface-color: #252525;
        --text-primary: #f2f2f2;
        --text-secondary: #9e9e9e;
        --border-color: rgba(255, 255, 255, 0.12);
        --border-color-hover: rgba(255, 255, 255, 0.25);
        
        --input-bg: rgba(255, 255, 255, 0.05);
        --hover-bg: rgba(255, 255, 255, 0.08);
        --btn-secondary-bg: #2b2b2b;
        --btn-primary-text: #191919;
        --shadow-color: rgba(0, 0, 0, 0.4);
    }
}

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

.theme-text-light { display: inline; }
.theme-text-dark { display: none; }

:root[data-theme="dark"] .theme-text-light { display: none; }
:root[data-theme="dark"] .theme-text-dark { display: inline; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-text-light { display: none; }
    :root:not([data-theme="light"]) .theme-text-dark { display: inline; }
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    height: -webkit-fill-available;
    overflow: hidden;
    user-select: none;
}

.app-container {
    height: 100vh;
    height: 100dvh;
    width: 100%;
    margin: 0;
    position: relative;
    background: var(--bg-color);
}

.app-container.has-sidebar {
    display: grid;
    grid-template-columns: 240px 1fr;
}

.app-container.no-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-header {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    position: relative;
    z-index: 100;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

.app-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xl) 10%;
    position: relative;
    height: 100vh;
}

/* Typography */
h1, h2, h3, h4 { font-weight: 600; margin-bottom: var(--spacing-sm); letter-spacing: -0.02em; }
p { color: var(--text-primary); margin-bottom: var(--spacing-md); line-height: 1.5; }

/* Forms */
.form-group { margin-bottom: var(--spacing-md); }
.form-label { display: block; margin-bottom: var(--spacing-xs); font-size: 0.9rem; font-weight: 500; color: var(--text-secondary); }
.form-control {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--border-color-hover);
    background-color: var(--bg-color);
    box-shadow: var(--shadow-color) 0px 0px 0px 1px, var(--shadow-color) 0px 2px 4px;
    transform: none;
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 100%; padding: 8px 16px; border-radius: var(--radius-sm);
    font-weight: 500; font-size: 0.95rem; cursor: pointer; border: 1px solid transparent;
    transition: background 120ms ease-in 0s; text-decoration: none;
    text-transform: none; letter-spacing: normal;
}
.btn:active { transform: scale(0.98); box-shadow: none !important; }
.btn-primary { background: var(--primary); color: var(--btn-primary-text); box-shadow: none; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--text-primary); border: 1px solid var(--border-color); box-shadow: none; }
.btn-secondary:hover { background: var(--hover-bg); }
.btn-outline { background: transparent; color: var(--text-primary); border: 1px solid var(--border-color); box-shadow: none; }

/* Sidebar */
.sidebar {
    background: var(--secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}
.sidebar-header svg {
    width: 20px;
    height: 20px;
}
.sidebar-group {
    margin-top: 16px;
    padding: 0 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    margin: 2px 8px;
}
.sidebar-item:hover {
    background: var(--hover-bg);
}
.sidebar-item.active {
    background: var(--hover-bg);
    font-weight: 500;
}
.sidebar-item svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-secondary);
    flex-shrink: 0;
}

/* Collapsed Sidebar Styles */
body.sidebar-collapsed .app-container.has-sidebar {
    grid-template-columns: 64px 1fr;
}
body.sidebar-collapsed .sidebar {
    padding: 12px 0;
    align-items: center;
}
body.sidebar-collapsed .sidebar-header {
    padding: 12px 0;
    justify-content: center !important;
}
body.sidebar-collapsed .sidebar-title-box {
    display: none !important;
}
body.sidebar-collapsed .sidebar-text {
    display: none !important;
}
body.sidebar-collapsed .sidebar-item {
    padding: 10px;
    margin: 4px 8px;
    justify-content: center;
}
body.sidebar-collapsed .sidebar-group {
    padding: 0;
    text-align: center;
    margin-top: 16px;
    margin-bottom: 4px;
}
body.sidebar-collapsed .sidebar-group::after {
    content: "...";
}
body.sidebar-collapsed .sidebar-toggle-btn {
    margin: 0 auto;
}

/* Auth */
.auth-container { 
    display: flex; flex-direction: column; justify-content: center; 
    width: 100%; max-width: 400px; margin: 0 auto; 
}
.auth-header { text-align: left; margin-bottom: var(--spacing-xl); border-bottom: none; padding-bottom: 0; }
.auth-header h2 { font-size: 1.8rem; margin-bottom: var(--spacing-xs); text-transform: none; font-weight: 700; letter-spacing: -0.02em; }
.alert { padding: 8px 12px; border-radius: var(--radius-sm); margin-bottom: var(--spacing-md); background-color: rgba(235, 87, 87, 0.1); border: 1px solid rgba(235, 87, 87, 0.2); color: #eb5757; font-weight: 500; font-size: 0.9rem; text-transform: none; }
a { color: var(--text-secondary); text-decoration: underline; font-weight: 500; text-underline-offset: 2px;}
a:hover { background: transparent; color: var(--text-primary); }
.text-center { text-align: center; } .mt-md { margin-top: var(--spacing-md); } .mt-lg { margin-top: var(--spacing-lg); }

/* Swipe Deck (Tinder Style Mechanics, Notion Style UI) */
#swipe-deck {
    position: relative; width: 100%; height: 100%; margin: 0;
    perspective: 1000px;
}
.profile-card {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    border-radius: var(--radius-lg); overflow: hidden;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    box-shadow: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px, rgba(15, 15, 15, 0.1) 0px 3px 6px;
    transform-origin: 50% 100%;
    will-change: transform;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    text-align: center;
}
.profile-info {
    z-index: 2;
    display: flex; flex-direction: column;
    color: var(--text-primary); pointer-events: none;
    align-items: center;
}
.profile-info * { color: var(--text-primary) !important; }
.profile-name { font-size: 1.8rem; font-weight: 700; margin-bottom: 12px; letter-spacing: -0.02em; }
.profile-desc { font-size: 1rem; color: var(--text-secondary) !important; font-weight: 400; }
.intention-badge {
    display: inline-block; padding: 4px 8px; border-radius: 4px;
    background: rgba(15, 15, 15, 0.05) !important;
    color: var(--text-primary) !important; font-size: 0.75rem; font-weight: 500; margin-bottom: 12px;
    border: 1px solid var(--border-color) !important;
    text-transform: none; letter-spacing: normal;
}
.action-buttons {
    position: absolute; bottom: 20px; left: 0; right: 0;
    display: flex; justify-content: center; gap: 24px; padding: 0 var(--spacing-md);
    z-index: 3; background: transparent; pointer-events: none;
}
.btn-action {
    width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color); cursor: pointer; background: var(--btn-secondary-bg); pointer-events: auto;
    box-shadow: 0 4px 12px var(--shadow-color); transition: transform 0.2s ease, background 0.2s ease;
}
.btn-action:active { transform: scale(0.9); box-shadow: 0 2px 6px var(--shadow-color); background: var(--hover-bg); }
.btn-reject { color: var(--text-primary); }
.btn-like { color: var(--text-primary); }

/* Animations */
.animate-slide-up { animation: slideUp 0.3s ease-out forwards; }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Whiteboard Text */
.editable-content {
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    outline: none;
    overflow: hidden;
}

/* Base Card (Kanban Style Pattern) */
.base-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    box-sizing: border-box;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s, transform 0.2s;
    overflow: hidden;
}
.base-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.text-break-safe {
    word-break: break-all;
    overflow-wrap: break-word;
}

/* Accessibility & Focus Rings */
:focus-visible {
    outline: 2px solid #2F80ED;
    outline-offset: 2px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid #2F80ED;
    outline-offset: -1px;
}

.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #2F80ED;
    color: white;
    padding: 8px;
    z-index: 9999;
    text-decoration: none;
    font-weight: bold;
    border-radius: 0 0 4px 0;
    transition: top 0.2s;
}
.skip-to-content:focus {
    top: 0;
}

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

.shortcut-badge {
    margin-left: auto;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    opacity: 0.6;
    background: var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    flex-shrink: 0;
}
body.sidebar-collapsed .shortcut-badge {
    display: none !important;
}

body.sidebar-collapsed #globalPomodoroWidget {
    padding: 8px 0 !important;
    justify-content: center;
    background: transparent !important;
    border-color: transparent !important;
}
body.sidebar-collapsed #widgetTextContainer {
    display: none !important;
}

/* RESPONSIVO: SIDEBAR MOBILE */
@media (max-width: 768px) {
    /* 1. Reset da grade principal para ser apenas 1 coluna */
    .app-container.has-sidebar, 
    body.sidebar-collapsed .app-container.has-sidebar {
        display: flex;
        flex-direction: column;
    }
    
    /* 2. Mostra o botão flutuante de menu */
    #mobileSidebarToggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    /* 3. A sidebar vira um painel deslizante por cima (overlay) */
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(0); /* Aberta */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        width: 280px !important;
        box-shadow: 4px 0 16px rgba(0,0,0,0.1);
    }
    
    /* 4. Quando fechada, ela sai TOTALMENTE da tela (some) */
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }

    /* 5. Quando fechada, resetamos os estilos de "icones" para que
       quando ela estiver aberta (traduzindo, translateX(0)), ela
       apareça por inteiro normal, sem estar "apertada". */
    body.sidebar-collapsed .sidebar-header,
    body.sidebar-collapsed .sidebar-item,
    body.sidebar-collapsed .sidebar {
        padding: inherit;
        align-items: inherit;
        justify-content: inherit;
    }
    body.sidebar-collapsed .sidebar-title-box,
    body.sidebar-collapsed .sidebar-text,
    body.sidebar-collapsed .shortcut-badge,
    body.sidebar-collapsed #globalPomodoroWidget,
    body.sidebar-collapsed #widgetTextContainer {
        display: inherit !important;
    }
    body.sidebar-collapsed .sidebar-group::after {
        content: none;
    }
    body.sidebar-collapsed .sidebar-group {
        text-align: inherit;
        padding: inherit;
    }
}
