/* Reset e configurações básicas */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --secondary: #764ba2;
    --accent: #a29bfe;
    --success: #00b894;
    --danger: #ff7675;
    --dark: #1a1a2e;
    --dark-lighter: #252540;
    --dark-card: rgba(30, 30, 50, 0.95);
    --text-light: #e0e7ff;
    --text-dim: #c7d2fe;
    --border: rgba(102, 126, 234, 0.3);
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-gradient);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    padding-bottom: 2rem;
    transition: background 0.3s ease, color 0.3s ease;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Navegação */
nav {
    background: var(--nav-bg);
    backdrop-filter: blur(15px);
    border-bottom: 2px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 0;
    z-index: 1000;
    animation: slideDownNav 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes slideDownNav {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }
    60% {
        transform: translateY(10px);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    padding: 1.5rem 2rem;
    gap: 1.2rem;
    max-width: 1200px;
    margin: 0 auto;
}

nav li {
    animation: fadeInScale 0.5s ease-out backwards;
    animation-delay: calc(var(--nav-order) * 0.1s);
}

nav li:nth-child(1) { --nav-order: 1; }
nav li:nth-child(2) { --nav-order: 2; }
nav li:nth-child(3) { --nav-order: 3; }
nav li:nth-child(4) { --nav-order: 4; }

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

nav a {
    text-decoration: none;
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.9rem 2rem;
    border-radius: 50px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.8), rgba(118, 75, 162, 0.8));
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

nav a:hover {
    background: linear-gradient(135deg, #667eea, #764ba2);
    transform: translateY(-4px) scale(1.08);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.5);
}

/* Header */
header {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    margin: 2.5rem auto;
    max-width: 1200px;
    border-radius: 30px;
    box-shadow: var(--shadow);
    animation: fadeInUp 0.8s ease-out;
    border: 2px solid var(--border-color);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1 {
    background: linear-gradient(135deg, #ffffff, #e0e7ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2.8rem;
    margin-bottom: 0.8rem;
    font-weight: 800;
    filter: drop-shadow(0 4px 8px rgba(102, 126, 234, 0.3));
}

/* Força h1 preto no modo claro */
:root:not([data-theme="dark"]) h1 {
    background: none !important;
    -webkit-text-fill-color: #000000 !important;
    color: #000000 !important;
}

header p {
    color: var(--text-dim);
    font-size: 1.2rem;
}

/* Força parágrafos pretos no modo claro */
:root:not([data-theme="dark"]) p {
    color: #000000 !important;
}

/* Main */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

section {
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    border-radius: 25px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    border: 2px solid var(--border-color);
    animation: fadeInUp 0.8s ease-out backwards;
}

.add-task-section {
    animation-delay: 0.2s;
}

.tasks-section {
    animation-delay: 0.4s;
}

h2 {
    color: var(--text-primary);
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
    text-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

/* Força h2 preto no modo claro */
:root:not([data-theme="dark"]) h2 {
    color: #000000 !important;
}

/* Formulário de tarefas */
.task-form {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

#taskInput {
    flex: 1;
    min-width: 250px;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
    font-family: inherit;
    transition: all 0.3s ease;
}

#taskInput:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

#taskInput::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
}

.btn-primary {
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    font-family: inherit;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.btn-primary:active {
    transform: translateY(-1px);
}

.btn-icon {
    font-size: 1.5rem;
    line-height: 1;
}

/* Header das tarefas */
.tasks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tasks-stats {
    display: flex;
    gap: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Lista de tarefas */
.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.task-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border: 2px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    animation: slideInLeft 0.5s ease-out backwards;
}

.task-card:hover {
    transform: translateX(5px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    border-color: var(--accent);
}

.task-card.completed {
    opacity: 0.6;
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.1), rgba(0, 184, 148, 0.05));
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.task-title-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.task-checkbox {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--success);
}

.task-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-light);
    flex: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.task-card.completed .task-title {
    text-decoration: line-through;
    opacity: 0.7;
}

.task-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon-only {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.btn-icon-only:hover {
    background: var(--danger);
    transform: scale(1.1);
}

.btn-add-topic {
    background: rgba(102, 126, 234, 0.2);
}

.btn-add-topic:hover {
    background: var(--primary);
}

/* Tópicos */
.topics-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.topic-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.topic-input {
    flex: 1;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
    font-family: inherit;
}

.topic-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.2);
}

.btn-small {
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-family: inherit;
}

.btn-small:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.topics-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.topic-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border-left: 3px solid var(--accent);
    transition: all 0.3s ease;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.topic-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(5px);
}

.topic-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--success);
}

.topic-text {
    flex: 1;
    color: var(--text-dim);
    font-size: 0.95rem;
}

.topic-item.completed .topic-text {
    text-decoration: line-through;
    opacity: 0.6;
}

.btn-delete-topic {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.btn-delete-topic:hover {
    background: var(--danger);
    color: white;
    transform: scale(1.1);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-dim);
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 1rem;
}

/* Responsividade */
/* Mobile First Otimizado */

/* Garantir áreas de toque adequadas */
button,
.task-checkbox,
.topic-checkbox,
.btn-icon-only {
    min-width: 44px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

/* Prevenir zoom no iOS */
input,
textarea {
    font-size: 16px !important;
}

/* Smooth scroll */
* {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 1024px) {
    main {
        max-width: 95%;
        padding: 0 1rem;
    }
}

@media (max-width: 768px) {
    body {
        padding-bottom: 1rem;
    }

    nav ul {
        padding: 0.85rem 0.75rem;
        gap: 0.6rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    nav ul::-webkit-scrollbar {
        height: 3px;
    }

    nav ul::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 3px;
    }
    
    nav a {
        font-size: 0.85rem;
        padding: 0.7rem 1.25rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.3rem;
    }
    
    header, section {
        padding: 1.25rem 1rem;
        margin: 0.75rem 0.5rem;
        border-radius: 18px;
    }
    
    .task-form {
        flex-direction: column;
        gap: 0.85rem;
    }
    
    #taskInput {
        min-width: 100%;
        font-size: 16px;
        padding: 0.9rem 1rem;
    }
    
    .btn-primary {
        width: 100%;
        justify-content: center;
        padding: 0.9rem;
        font-size: 0.95rem;
    }

    .btn-icon {
        font-size: 1.3rem;
    }
    
    .tasks-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1.25rem;
    }
    
    .tasks-stats {
        width: 100%;
        justify-content: space-around;
        gap: 1rem;
    }

    .stat-card {
        flex: 1;
        min-width: 120px;
    }
    
    .task-card {
        padding: 1.35rem 1.15rem;
        margin-bottom: 1rem;
    }
    
    .task-header {
        flex-wrap: wrap;
        gap: 0.85rem;
    }
    
    .task-title-wrapper {
        gap: 0.85rem;
        min-width: 0;
        flex: 1 1 100%;
    }
    
    .task-title {
        font-size: 1.05rem;
        line-height: 1.5;
    }

    .task-actions {
        width: 100%;
        justify-content: flex-end;
        gap: 0.6rem;
    }

    .btn-icon-only {
        width: 40px;
        height: 40px;
        font-size: 1.05rem;
        border-radius: 10px;
    }

    .topics-list {
        margin-top: 1rem;
    }

    .topic-item {
        padding: 0.85rem;
    }
}

@media (max-width: 480px) {
    body {
        padding-bottom: 0.5rem;
    }

    nav ul {
        padding: 0.85rem 0.5rem;
        gap: 0.6rem;
    }

    nav a {
        font-size: 0.85rem;
        padding: 0.7rem 1.25rem;
        border-radius: 12px;
    }

    h1 {
        font-size: 1.65rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    header, section {
        padding: 1.25rem 1rem;
        margin: 0.75rem 0.35rem;
        border-radius: 18px;
    }

    header p {
        font-size: 0.95rem;
    }

    .task-form {
        gap: 0.75rem;
    }

    #taskInput {
        padding: 0.85rem 0.95rem;
        font-size: 15px;
        border-radius: 14px;
    }

    .btn-primary {
        padding: 0.85rem;
        font-size: 0.9rem;
        border-radius: 12px;
    }

    .btn-icon {
        font-size: 1.15rem;
    }

    .tasks-stats {
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .stat-card {
        padding: 1rem 0.85rem;
        border-radius: 14px;
        min-width: calc(50% - 0.4rem);
    }
    
    .stat-number {
        font-size: 1.6rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }
    
    .task-card {
        padding: 1.15rem 0.95rem;
        margin-bottom: 0.85rem;
        border-radius: 16px;
    }
    
    .task-title {
        font-size: 0.98rem;
        line-height: 1.45;
    }
    
    .task-header {
        gap: 0.75rem;
    }

    .task-checkbox {
        width: 22px;
        height: 22px;
    }
    
    .task-actions {
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .btn-icon-only {
        width: 38px;
        height: 38px;
        font-size: 1rem;
        border-radius: 9px;
    }

    .topics-form {
        gap: 0.6rem;
    }

    .topic-input {
        padding: 0.75rem 0.85rem;
        font-size: 15px;
        border-radius: 12px;
    }

    .btn-small {
        padding: 0.7rem 0.9rem;
        font-size: 0.8rem;
        border-radius: 10px;
    }

    .topics-list {
        gap: 0.65rem;
        margin-top: 0.85rem;
    }

    .topic-item {
        padding: 0.75rem 0.85rem;
        border-radius: 12px;
    }
    
    .topic-text {
        font-size: 0.9rem;
    }

    .topic-checkbox {
        width: 18px;
        height: 18px;
    }

    .btn-delete-topic {
        width: 28px;
        height: 28px;
        font-size: 1rem;
        border-radius: 7px;
    }

    .empty-state {
        padding: 2.5rem 1.25rem;
    }

    .empty-state-icon {
        font-size: 3rem;
    }

    .empty-state p {
        font-size: 0.95rem;
    }
}

/* iPhone SE e telas muito pequenas */
@media (max-width: 375px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.15rem;
    }

    header, section {
        padding: 1.1rem 0.85rem;
        margin: 0.65rem 0.25rem;
    }

    .btn-primary {
        padding: 0.8rem;
        font-size: 0.85rem;
        border-radius: 11px;
    }

    .btn-icon {
        font-size: 1.1rem;
    }

    .stat-card {
        padding: 0.9rem 0.75rem;
        min-width: calc(50% - 0.35rem);
    }

    .stat-number {
        font-size: 1.4rem;
    }

    .task-card {
        padding: 1rem 0.85rem;
    }

    .task-title {
        font-size: 0.93rem;
    }

    .btn-icon-only {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
        border-radius: 8px;
    }

    .btn-small {
        padding: 0.65rem 0.8rem;
        font-size: 0.75rem;
        border-radius: 9px;
    }

    .btn-delete-topic {
        width: 26px;
        height: 26px;
        font-size: 0.95rem;
        border-radius: 6px;
    }
}

/* PWA Standalone */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Landscape para smartphones */
@media (max-height: 500px) and (orientation: landscape) {
    header, section {
        margin: 0.5rem 0.35rem;
        padding: 1rem;
    }

    h1 {
        font-size: 1.4rem;
    }

    .tasks-stats {
        flex-wrap: nowrap;
    }
}
