/* Estilos Gerais */
html, body {
    height: 100%;
}

/* Evita zoom/auto-ajuste de fonte no iOS e remove scroll lateral acidental */
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f9;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}

body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
}

.hidden {
    display: none !important; /* Adicionado !important para garantir a sobreposição */
}

/* --- Página de Login --- */
.login-container {
    background-color: #fff;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
    margin-top: 10vh;
}

.login-page .login-container {
    margin-top: 0;
}

.login-container h1 {
    margin-bottom: 25px;
    color: #2c3e50;
}

.login-container input[type="password"] {
    width: calc(100% - 20px);
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px; /* evita zoom no iOS */
}

.login-container input[type="text"] {
    width: calc(100% - 20px);
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px; /* evita zoom no iOS */
}

.login-container input[type="email"] {
    width: calc(100% - 20px);
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px; /* evita zoom no iOS */
}

.login-container button {
    width: 100%;
    padding: 12px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    margin-top: 15px;
}

.login-container button:hover {
    background-color: #2980b9;
}

.button-group {
    display: flex;
    gap: 10px;
}

.error-message {
    color: #e74c3c;
    margin-top: 15px;
    height: 20px;
}

.remember-row {
    text-align: left;
    margin: -10px 0 10px 2px;
    color: #555;
    font-size: 14px;
}

/* --- Planner Principal --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

header div {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

#add-task-button, #logout-button {
    padding: 10px 20px;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

#add-task-button {
    background-color: #2ecc71;
}

#add-task-button:hover {
    background-color: #27ae60;
}

#logout-button {
    background-color: #e74c3c;
}

#logout-button:hover {
    background-color: #c0392b;
}

#toggle-completed-tasks {
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

#toggle-completed-tasks:hover {
    background-color: #2980b9;
}

.planner-container {
    padding: 2rem;
    width: 100%; /* Ocupa a largura total */
    max-width: 1400px; /* Aumenta a largura máxima */
    margin: 0 auto; /* Centraliza o container */
    box-sizing: border-box; /* Garante que o padding não adicione largura extra */
    flex-grow: 1; /* Faz o container crescer para ocupar o espaço */
}

.week-view {
    display: flex;
    flex-direction: column; /* Organiza os grupos de data verticalmente */
    gap: 2rem;
}

.date-group {
    width: 100%;
}

.date-header {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    color: #555;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.client-group {
    margin-bottom: 1.5rem;
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.client-header {
    display: flex;
    align-items: center;
    gap: 50px;
}

.client-header .client-name {
    margin: 0 0 0.75rem 0; /* mantém espaço abaixo do cabeçalho */
}

.client-name {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 0.75rem;
    color: #007bff;
}

.delete-client-btn {
    margin: 0;
    padding: 4px 8px; /* menor */
    background: #ffe6e9;
    color: #dc3545;
    border: 1px solid #ffc2c9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px; /* menor */
    line-height: 1.1;
}

.delete-client-btn:hover {
    background: #ffd6db;
}

.responsible-group {
    margin-left: 20px; /* Indenta o responsável */
    margin-bottom: 1rem;
}

.responsible-name {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.task-list {
    list-style: none;
    padding-left: 20px; /* Indenta as tarefas */
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.task-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-radius: 4px;
    background-color: #f9f9f9;
    border-left: 3px solid #007bff;
}

.task-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-grow: 1; /* Faz a descrição da tarefa ocupar o espaço disponível */
}

.task-info input[type="checkbox"] {
    cursor: pointer;
}

.task-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* Ajustado para melhor espaçamento */
    color: #666;
}

.edit-task-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.05rem;
    color: #555;
    padding: 0;
}

.edit-task-btn:hover {
    color: #2c3e50;
}

.task-creation-time {
    font-size: 0.8rem;
    color: #999;
}

.task-age {
    font-size: 0.85rem;
    font-style: italic;
    width: 50px;
}

.delete-task-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: #dc3545;
    padding: 0;
}

.delete-task-btn:hover {
    color: #a71d2a;
}

.task-info .task-creator {
    font-size: 0.6rem; /* ~7pt, small and discreet */
    color: #999;       /* light gray */
    white-space: nowrap;
}

/* Estilos para tarefas completas (se necessário) */
.task-item.completed .task-info span {
    text-decoration: line-through;
    color: #888;
}

/* Remove estilos antigos de card */
.client-card,
.client-card-header,
.client-tasks,
.responsible-subcategory,
.responsible-task-list {
    all: unset;
}

/* --- Seção de Concluídos --- */
.completed-tasks-container {
    box-sizing: border-box; /* garante que o padding não cause overflow */
    width: 100%;
    margin: 40px 0 0 0;
    background-color: #fff;
    padding: 20px;
    border-radius: 0; /* sem cantos arredondados para preencher até o fim */
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

#completed-tasks {
    margin-top: 30px;
    background-color: #f9f9f9;
}

#completed-list li {
    list-style-type: '✔';
    margin-left: 20px;
    padding-left: 10px;
    color: #27ae60;
    
}

/* --- Modal --- */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

#task-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#task-form input, #task-form select {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px; /* evita zoom no iOS */
}

#task-form textarea { font-size: 16px; }

#task-form button {
    padding: 12px;
    background-color: #2ecc71;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

#task-form button:hover {
    background-color: #27ae60;
}

/* --- Prioridade nas tarefas --- */
.task-meta .priority-select {
    font-weight: 700;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.85rem;
    margin-left: 2px;
}
.priority-select.priority-high { color: #b71c1c; background-color: #ffebee; border-color: #ffcdd2; }
.priority-select.priority-medium { color: #bf360c; background-color: #fff3e0; border-color: #ffe0b2; }
.priority-select.priority-low { color: #1b5e20; background-color: #e8f5e9; border-color: #c8e6c9; }

/* --- Responsividade --- */

@media (max-width: 992px) { /* Novo breakpoint para tablets */
    .week-view {
        display: grid; /* Volta para grid em telas menores */
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
    .task-item {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem;
        border-radius: 4px;
        background-color: #f9f9f9;
        border-left: 3px solid #007bff;
    }
}

@media (max-width: 768px) {
    body { padding: 0; }

    header {
        flex-direction: column;
        align-items: stretch; /* Estica os itens para preencher a largura */
        gap: 10px;
        margin-bottom: 12px;
        padding: 10px; /* reduz padding lateral */
        box-sizing: border-box;
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }
    .task-meta {
        display: flex;
        justify-content: space-between;
        padding-top: 10px;
        width: 95%;
        align-items: center;
        gap: 0.5rem; /* Ajustado para melhor espaçamento */
        color: #666;
    }

    .task-item {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: space-between;
        padding: 0.75rem;
        border-radius: 4px;
        background-color: #f9f9f9;
        border-left: 3px solid #007bff;
    }

    header h1 {
        text-align: center; /* Centraliza o título */
    }

    #add-task-button, #logout-button { margin: 0; }

    .week-view {
        grid-template-columns: 1fr; /* 1 coluna para telas pequenas */
        gap: 12px;
    }

    .day-column {
        min-height: auto; /* Remove a altura mínima */
        padding: 15px;
    }

    .planner-container {
        padding: 10px;
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
        box-sizing: border-box;
    }

    .client-group
    {
        padding: 10px;
    }
    .task-list { padding-left: 2px; }
    .responsible-group { margin-left: 12px; }

    .completed-tasks-container {
        margin: 20px 0 0 0;
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
        border-radius: 0; /* ocupa de ponta a ponta */
        box-sizing: border-box;
    }
}

/* feedback visual ao arrastar */
.task-item.dragging {
    opacity: 0.6;
}

/* --- Mobile Drag Toggle Button --- */
.drag-toggle {
    position: fixed;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 900;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    border: none;
    border-radius: 9999px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    backdrop-filter: saturate(180%) blur(8px);
    display: none; /* hidden by default; shown on mobile */
    cursor: pointer;
}
.drag-toggle[aria-pressed="false"] {
    background: rgba(90, 90, 90, 0.8);
}
.drag-toggle:active {
    transform: translateY(1px);
}
@media (max-width: 768px) {
    .drag-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }
}
