/* css/style.css */
:root {
    /* Paleta Dark Mode */
    --bg-color: #181818;       
    --container-bg: #242424;   
    
    /* Azul Electrosol - RGB 17,51,87 */
    --primary: rgb(17, 51, 87);
    --primary-hover: rgb(25, 70, 120); 
    
    --text: #e0e0e0;           
    --text-muted: #a0a0a0;     
    
    --input-bg: #2d2d2d;       
    --border: #3d3d3d;         
    --danger: #ff6b6b;         
}

* { box-sizing: border-box; font-family: 'Segoe UI', 'Roboto', Helvetica, Arial, sans-serif; }

html, body {
    overflow-x: hidden; 
}

body {
    background-color: var(--bg-color);
    color: var(--text);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 1000px; 
    background: var(--container-bg);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5); 
    padding: 2rem;
    border: 1px solid var(--border);
    position: relative; 
    margin-bottom: auto; 
}

/* --- TELA DE LOGIN --- */
.login-box { text-align: center; max-width: 400px; margin: 0 auto; }
.login-box h2 { color: var(--text); margin-bottom: 0.5rem; }
.login-subtitle { color: var(--text-muted); margin-bottom: 20px; font-size: 0.9em; }
.login-box img { max-width: 100%; height: auto; }

.input-group {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 10px;
    background: var(--input-bg);
    transition: border 0.2s;
    width: 100%;
}
.input-group:focus-within { border-color: #4a9eff; }

.input-group input {
    background: transparent;
    border: none;
    outline: none;
    padding: 12px;
    flex-grow: 1;
    font-size: 16px;
    color: var(--text);
    border-radius: 4px;
    min-width: 0;
}

.input-group .suffix {
    background-color: #333;
    color: var(--text-muted);
    padding: 12px;
    font-size: 14px;
    border-left: 1px solid var(--border);
    user-select: none;
    white-space: nowrap;
}

.btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}
.btn:hover { background-color: var(--primary-hover); }

/* --- GRID DE CATEGORIAS --- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.category-card {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}
.category-card:hover { background: var(--primary); border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.category-icon { font-size: 32px; margin-bottom: 10px; }
.category-name { font-size: 14px; font-weight: 600; color: var(--text); }


/* --- APP PRINCIPAL --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.btn-back { background: none; border: none; color: var(--text); font-size: 24px; cursor: pointer; padding: 0 5px; }
.btn-back:hover { color: #4a9eff; }
header h2 { margin: 0; font-size: 1.5rem; color: var(--text); }
.user-info { font-size: 0.9rem; color: var(--text-muted); display: flex; flex-direction: column; text-align: right; }
.user-info #display-name { color: #fff; font-weight: bold; }
.user-action-links { margin-top: 5px; font-size: 0.85rem; }
.btn-link { background: none; border: none; color: #4a9eff; cursor: pointer; text-decoration: none; padding: 0; margin-right: 10px; }
.btn-link:hover { text-decoration: underline; }
.btn-logout { background: none; border: none; color: var(--danger); cursor: pointer; text-decoration: none; padding: 0; }
.btn-logout:hover { text-decoration: underline; }

/* --- ÁREA DE NOVA TAREFA --- */
.add-task-wrapper { 
    display: flex; 
    margin-bottom: 20px; 
    position: relative;
    align-items: stretch;
}

#new-task-input {
    flex-grow: 1;
    padding: 12px;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 4px 0 0 4px;
    font-size: 16px;
    outline: none;
    min-width: 0; 
}
#new-task-input:focus { border-color: #4a9eff; }

.btn-upload {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-left: none;
    border-right: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}
.btn-upload:hover { color: #fff; }
.btn-upload.has-file { color: #4a9eff; } 

.btn-add {
    border-radius: 0 4px 4px 0;
    width: auto;
    margin-top: 0;
    padding: 0 20px;
    font-weight: bold;
    font-size: 1.5rem;
    line-height: 1;
    background: var(--primary);
    border: 1px solid var(--primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Lista de Tarefas */
#task-list { list-style: none; padding: 0; margin: 0; }
.task-item {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    background: var(--container-bg);
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
    animation: fadeIn 0.3s ease;
}
.task-item:hover { background-color: #2e2e2e; }

.custom-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    margin-right: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-top: 2px;
}
.task-item.completed .custom-checkbox { background-color: var(--primary); border-color: var(--primary); }
.task-item.completed .custom-checkbox::after { content: '✓'; color: white; font-size: 14px; }

.task-text { 
    flex-grow: 1; 
    font-size: 16px; 
    cursor: pointer; 
    color: var(--text); 
    line-height: 1.4; 
    padding: 2px 0; 
    word-break: break-word; 
    overflow-wrap: break-word;
}
.task-item.completed .task-text { text-decoration: line-through; color: var(--text-muted); }

.task-actions { display: flex; gap: 5px; flex-shrink: 0; margin-left: 10px; }
.btn-icon { background: none; border: none; color: #555; cursor: pointer; font-size: 18px; padding: 8px; transition: color 0.2s; }
.btn-icon:hover { color: var(--text); }
.btn-icon.delete:hover { color: var(--danger); }
.btn-icon.image-link { color: #4a9eff; } 
.btn-icon.info { color: #888; }
.btn-icon.info:hover { color: #fff; }

/* MODAIS */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex; justify-content: center; align-items: center;
    z-index: 2000; backdrop-filter: blur(3px);
}
.modal-content {
    background: var(--container-bg); padding: 2rem; border-radius: 8px; border: 1px solid var(--border);
    width: 90%; max-width: 400px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); animation: fadeIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-image-content {
    background: transparent; border: none; box-shadow: none; padding: 0; max-width: 90%; max-height: 90%; text-align: center;
    overflow: hidden;
}
.modal-image-content img { max-width: 100%; max-height: 80vh; border-radius: 8px; box-shadow: 0 0 20px rgba(0,0,0,0.8); }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { margin: 0; color: var(--text); }
.btn-close-modal { background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; }
.modal-content label { display: block; color: var(--text-muted); margin-bottom: 5px; font-size: 0.9rem; }

/* LISTA DE DETALHES */
.task-details-list { list-style: none; padding: 0; margin: 0; font-size: 0.95rem; color: var(--text); }
.task-details-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.task-details-list li:last-child { border-bottom: none; }
.detail-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2px; }
.detail-value { font-weight: 500; }

/* ESTILOS ADMIN PAINEL */
.cat-manage-list, .deleted-tasks-list { list-style: none; padding: 0; margin: 10px 0 20px 0; max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: 4px; background: var(--input-bg); }
.cat-manage-item, .deleted-task-item { display: flex; justify-content: space-between; padding: 10px; border-bottom: 1px solid var(--border); align-items: center; }
.cat-manage-item:last-child, .deleted-task-item:last-child { border-bottom: none; }
.cat-manage-item span { font-size: 1.2rem; margin-right: 10px; }

/* Título das seções do admin */
.admin-section-title { 
    font-size: 1rem; 
    color: var(--text); 
    margin-bottom: 10px; 
    border-bottom: 1px solid var(--border); 
    padding-bottom: 5px; 
    margin-top: 20px; 
}
.admin-section-title:first-child { margin-top: 0; }

.task-content-wrapper { flex-grow: 1; min-width: 0; }
.task-meta { display: block; font-size: 0.75rem; color: #888; margin-top: 2px; }
.emoji-help-link { display: block; font-size: 0.75rem; color: #666; text-decoration: none; margin-top: -5px; margin-bottom: 5px; text-align: right; }
.emoji-help-link:hover { color: #4a9eff; text-decoration: underline; }

/* Rodapé */
.app-footer { text-align: center; font-size: 0.75rem; color: #666; margin-top: 20px; padding-bottom: 20px; display: flex; justify-content: center; align-items: center; gap: 6px; width: 100%; }
.app-footer a { color: #888; text-decoration: none; font-weight: 500; }
.app-footer img { width: 16px; height: auto; opacity: 0.8; }

.btn-restore { background: none; border: none; cursor: pointer; font-size: 1.2rem; }
.btn-restore:hover { transform: scale(1.1); }
.deleted-meta { font-size: 0.75rem; color: #777; display: block; }

/* TOOLTIPS */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
    content: attr(data-tooltip); position: absolute; background: #333; color: #fff; font-size: 12px;
    padding: 6px 10px; border-radius: 4px; white-space: nowrap; bottom: 100%; left: 50%; transform: translateX(-50%);
    margin-bottom: 10px; box-shadow: 0 4px 8px rgba(0,0,0,0.4); border: 1px solid #555; z-index: 1000; pointer-events: none; display: block;
}
[data-tooltip]:hover::before {
    content: ''; position: absolute; border: 6px solid transparent; border-top-color: #555;
    bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: -2px; z-index: 1000; pointer-events: none; display: block;
}

/* --- NOVOS ESTILOS: SPINNER E PREVIEW --- */

/* Spinner para Loading */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Estado carregando do botão */
.btn-loading {
    opacity: 0.7;
    pointer-events: none; /* Bloqueia cliques repetidos */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Prévia de Imagens */
#preview-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.preview-thumb {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

@media (max-width: 600px) {
    body { padding: 0; align-items: center; } 
    .container { border-radius: 0; border: none; padding: 1rem; min-height: auto; flex-grow: 1; box-shadow: none; width: 100%; }
    .btn-add { width: 50px; padding: 0; } 
    [data-tooltip]:hover::after, [data-tooltip]:hover::before { display: none; }
    .category-grid { grid-template-columns: repeat(2, 1fr); }
    .input-group .suffix { font-size: 12px; padding: 12px 8px; }
    .input-group input { font-size: 14px; }
    .btn-back { padding: 10px; }
    .modal-content { width: 95%; padding: 1.5rem; }
    .app-footer { margin-top: 10px; padding-bottom: 15px; }
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.hidden { display: none !important; }