:root {
    --bg-color: #f0f2f5;
    --card-bg-color: #ffffff;
    --primary-text-color: #1c1c1e;
    --secondary-text-color: #8e8e93;
    --accent-color: #007aff;
    --accent-color-hover: #005bb5;
    --border-color: #d1d1d6;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --error-color: #ff3b30;
}

html {
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--primary-text-color);
    line-height: 1.5;
}

#app-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
    transition: all 0.3s ease;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
}

.lang-switcher button {
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s, color 0.2s;
}

.lang-switcher button.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.lang-switcher button:not(.active):hover {
    background-color: #e9e9e9;
}


#add-todo-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.input-wrapper {
    position: relative;
    flex-grow: 1;
}

#todo-input {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background-color: var(--card-bg-color);
    transition: border-color 0.2s;
}

#todo-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}

#todo-input:focus + label,
#todo-input:valid + label {
    transform: translateY(-22px) scale(0.8);
    background: var(--bg-color);
    padding: 0 0.2rem;
    color: var(--accent-color);
}

.input-wrapper label {
    position: absolute;
    left: 1rem;
    top: 0.8rem;
    color: var(--secondary-text-color);
    pointer-events: none;
    transition: all 0.2s ease-in-out;
    background: transparent;
    font-size: 1rem;
}


#add-todo-form button {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: white;
    background-color: var(--accent-color);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

#add-todo-form button:hover {
    background-color: var(--accent-color-hover);
}

#task-list-container h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

#todo-list {
    list-style-type: none;
}

.task-item {
    background-color: var(--card-bg-color);
    margin-bottom: 0.75rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: all 0.3s ease;
    overflow: hidden; /* For animations */
}

.task-content {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.task-title {
    flex-grow: 1;
    font-size: 1.1rem;
}

.task-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.task-time {
    font-size: 0.9rem;
    color: var(--secondary-text-color);
    background-color: var(--bg-color);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
}

.decompose-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.2s;
}
.decompose-btn:hover {
    background-color: #e9e9eb;
    transform: rotate(90deg);
}

.decompose-btn svg {
    width: 24px;
    height: 24px;
    fill: var(--accent-color);
}


.subtask-list {
    list-style-type: none;
    padding-left: 2rem;
    background-color: rgba(0, 0, 0, 0.03);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out, padding 0.5s ease-in-out;
}

.subtask-list.show {
    padding: 1rem 0 1rem 2rem;
    max-height: 1000px; /* Arbitrary large value */
}

.subtask-list .task-item {
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}


/* Task details */
.task-details {
    padding: 0 1.5rem 1rem 48px; /* Align with title */
    color: var(--secondary-text-color);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease;
}

.task-details.show {
    max-height: 500px;
    padding-bottom: 1rem;
}
.task-details ul {
    list-style-type: '–  ';
    padding-left: 1.2rem;
}

.task-title-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 8px;
}

.toggle-details-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.toggle-details-btn.open {
    transform: rotate(90deg);
}


/* Loader styles */
.hidden { display: none !important; }

#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

#loader p {
    font-size: 1.1rem;
    font-weight: 500;
}


/* Custom Alert */
#custom-alert {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    padding: 1rem;
}
.alert-content {
    background: var(--card-bg-color);
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.alert-content h3 {
    color: var(--error-color);
    margin-bottom: 1rem;
}
.alert-content p {
    margin-bottom: 1.5rem;
}
#alert-close-btn {
    width: 100%;
    padding: 0.8rem;
    font-size: 1rem;
    color: white;
    background-color: var(--accent-color);
    border: none;
    border-radius: 10px;
    cursor: pointer;
}

/* Responsive styles */
@media (max-width: 600px) {
    body { font-size: 16px; }
    #app-container { margin: 1rem auto; }
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    header h1 { font-size: 1.8rem; }
    #add-todo-form {
        flex-direction: column;
    }
    .task-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .task-meta {
        width: 100%;
        justify-content: space-between;
    }
    .subtask-list {
        padding-left: 1rem;
    }
    .subtask-list.show {
        padding: 1rem 0 1rem 1rem;
    }
}
