/* General Body & Font Styles */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #333;
}

/* --- APP HEADER --- */
.app-header {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4rem;
    margin-top: 4rem;
    padding: 0;
    border: none;
    box-shadow: none;
    border-radius: 0;
    gap: 1.2rem;
}
.app-header h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 1.2rem;
}
.app-header > div {
    display: flex;
    align-items: center;
    gap: 1rem;
}
#logout-btn {
    margin: 0;
    align-self: auto;
}

/* Logout button at bottom left of app container */
.logout-bottom {
    margin-top: 0;
    margin-left: 0;
    padding: 0.4rem 1.1rem;
    font-size: 0.98rem;
    min-width: 80px;
    max-width: 120px;
}

#welcome-message {
    font-size: 1.1rem;
    font-weight: 400;
    color: #444;
    display: flex;
    align-items: center;
    height: 100%;
}

/* Main Containers */
.auth-container, .app-container {
    width: 100%;
    max-width: 600px;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    padding-top: 0;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

@media (min-width: 768px) {
    .app-container {
        max-width: 800px;
    }
}

/* Card-like Wrapper */
.auth-form-wrapper, .task-input-container, .task-list-container {
    background-color: #ffffff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    width: 100%;
    max-width: 400px; /* Adjusted for login forms */
    margin: 0 auto;
}

.task-input-container, .task-list-container {
    max-width: 600px; /* Adjusted for task containers */
}

/* Forms */
form {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    width: 100%;
}

.auth-form-wrapper form {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
}

input[type="text"], input[type="password"], input[type="number"] {
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    flex-grow: 1;
}

input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus {
    outline: none;
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Add more spacing between form groups and button for better layout */
.auth-form-wrapper form .form-group {
    margin-bottom: 0rem;
}

.form-group label {
    margin-bottom: 0.6rem;
    display: block; /* Ensures margin-bottom works correctly */
}

.auth-form-wrapper form .btn {
    margin-top: 1rem;
}

/* --- TASK FORM --- */
.task-input-container form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.task-input-container input[type="text"],
.task-input-container input[type="number"] {
    width: 100%;
    box-sizing: border-box;
}
.task-input-container .btn {
    align-self: flex-end;
}

/* Buttons */
.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    background-color: #007aff;
    color: white;
}

.btn:hover {
    background-color: #005ecb;
}

.btn:active {
    transform: scale(0.98);
}

.btn-danger {
    background-color: #dc3545;
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-primary {
    background-color: #28a745;
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

.btn-primary:hover {
    background-color: #218838;
}

/* --- TASK LIST --- */
.task-list-container {
    width: 100%;
    margin-top: 1rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 2rem;
    max-width: 600px;
}

#task-list {
    width: 100%;
    padding: 0;
    margin: 0;
    list-style: none;
}

.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 0.8rem;
    transition: background-color 0.2s;
    box-sizing: border-box;
    gap: 1rem;
}

.task-item:hover {
    background-color: #f1f3f5;
}

.task-item.completed .task-text {
    text-decoration: line-through;
    color: #888;
}

.task-text {
    flex: 1 1 220px;
    min-width: 120px;
    max-width: 220px;
    overflow-wrap: break-word;
}

/* --- Progress Bar: Rounded corners and nice color --- */
progress {
    appearance: none;
    -webkit-appearance: none;
    border-radius: 12px;
    background-color: #e3eafc;
    overflow: hidden;
}
progress::-webkit-progress-bar {
    background-color: #e3eafc;
    border-radius: 12px;
}
progress::-webkit-progress-value {
    background-color: #007aff;
    border-radius: 12px;
    transition: width 0.3s;
}
progress::-moz-progress-bar {
    background-color: #007aff;
    border-radius: 12px;
}
progress[value] {
    color: #007aff;
    background-color: #e3eafc;
    border-radius: 12px;
}

/* --- Make progress bar match the height of the + icon button --- */
progress,
.task-item progress {
    width: 340px;
    height: 38px;
    min-height: 38px;
    max-height: 38px;
    vertical-align: middle;
}

/* Message Styling */
.message {
    text-align: center;
    margin-top: 1rem;
    font-weight: 500;
    min-height: 24px;
}

#auth-message.success, #task-message.success {
    color: #28a745;
}

#auth-message.error, #task-message.error {
    color: #dc3545;
}

/* Hide elements with .hidden */
.hidden {
    display: none !important;
}

/* --- TASK ACTIONS: Side by side, icon buttons --- */
.task-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.7rem;
}
.task-actions .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.7rem;
    min-width: 36px;
    min-height: 36px;
    font-size: 1.3rem;
    border-radius: 8px;
}
.task-actions .btn-danger {
    background-color: #dc3545;
    color: #fff;
}
.task-actions .btn-danger:hover {
    background-color: #c82333;
}
.task-actions .btn-primary {
    background-color: #28a745;
    color: #fff;
}
.task-actions .btn-primary:hover {
    background-color: #218838;
}

/* --- TASK ACTIONS: Make icon buttons 1:1 ratio and same size --- */
.task-actions .btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    max-width: 38px;
    max-height: 38px;
    padding: 0;
    font-size: 1.4rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.task-actions .btn svg {
    width: 22px;
    height: 22px;
    display: block;
}

/* After main actions: right align below white box */
.after-main-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
    max-width: 600px;
    align-self: flex-end;
}