/* 
========================================
   Base & Reset
======================================== 
*/
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #ec4899;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e1b4b;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --danger-color: #f43f5e;
    --success-color: #10b981;
    --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --border-radius: 16px;
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: #0f172a; /* Solid dark background to avoid any glow issues */
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Changed to flex-start but we add margin-top */
    padding: 2rem 1rem;
    overflow-x: hidden;
}

/* 
========================================
   App Container & Glassmorphism
======================================== 
*/
.app-container {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 900px;
    box-shadow: var(--shadow-soft);
    position: relative;
    z-index: 1;
    /* Animated entrance */
    animation: fadeInSlideUp 0.8s ease forwards;
    margin-top: 5vh;
}

.auth-container {
    max-width: 400px;
    margin-top: 15vh;
}

/* Glassmorphism focus */
.app-container:focus-within {
    border-color: rgba(99, 102, 241, 0.4);
}

/* 
========================================
   Header & User Info
======================================== 
*/
.header {
    text-align: center;
    margin-bottom: 2.5rem;
    position: relative;
}

.logout-container {
    position: absolute;
    top: -15px;
    right: -15px;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.logout-btn {
    background: rgba(244, 63, 94, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition-fast);
}

.logout-btn:hover {
    background: var(--danger-color);
    color: white;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.logo i {
    font-size: 2rem;
    color: var(--secondary-color);
    filter: drop-shadow(0 0 10px rgba(236, 72, 153, 0.5));
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, var(--text-muted));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 300;
    text-align: center;
    margin-bottom: 2rem;
}

/* 
========================================
   Buttons & Actions
======================================== 
*/
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.8rem 1.5rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* 
========================================
   Form / Auth
======================================== 
*/

.input-group {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1rem;
    position: relative;
}

.todo-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1rem 1.2rem;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1.05rem;
    transition: var(--transition-fast);
    width: 100%;
}

.todo-input::placeholder {
    color: rgba(148, 163, 184, 0.6);
}

.todo-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: rgba(0, 0, 0, 0.3);
}

.todo-submit-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 0 1.5rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 52px;
}

.w-full {
    width: 100%;
    margin-top: 1rem;
}

.todo-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

.todo-submit-btn:active {
    transform: translateY(0);
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-switch span {
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 600;
}

.auth-switch span:hover {
    text-decoration: underline;
}

.error-msg {
    color: var(--danger-color);
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 20px;
}

/* 
========================================
   Phase 3: Categories & Extensions
======================================== 
*/

.category-tabs, .tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 0.3rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--card-border);
    width: fit-content;
}

.category-tab, .tab-btn {
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    border-radius: 9px;
    transition: var(--transition-fast);
    font-weight: 500;
    color: var(--text-muted);
    border: none;
    background: transparent;
    font-family: inherit;
}

.category-tab.active, .tab-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Controls Row (Tabs + View Modes) */
.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.view-modes {
    display: flex;
    gap: 10px;
}

.view-btn {
    background: var(--bg-secondary);
    border: none;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Grid Layout */
.todo-list.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.todo-list.grid .todo-item {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
}

.todo-list.grid .todo-content {
    margin-bottom: 15px;
    width: 100%;
}

/* Compact Layout */
.todo-list.compact .todo-item {
    padding: 8px 15px;
    margin-bottom: 8px;
}

.todo-list.compact .todo-title {
    font-size: 0.95rem;
}

/* Admin Table */
.admin-table-container {
    overflow-x: auto;
    margin-top: 20px;
}

#users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#users-table th, #users-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: rgba(46, 204, 113, 0.2); color: #2ecc71; }
.badge-warning { background: rgba(241, 196, 15, 0.2); color: #f1c40f; }
.badge-danger { background: rgba(231, 76, 60, 0.2); color: #e74c3c; }

.todo-form-extended {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: none; /* Toggled by a button */
}

.todo-form-extended.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-field label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-input-styled {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    color: var(--text-color);
    font-family: inherit;
}

.form-input-styled:focus {
    outline: none;
    border-color: var(--primary-color);
}

.toggle-extended-btn {
    background: transparent;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
}

/* Tags in list */
.tag-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(99, 102, 241, 0.2);
    font-weight: 600;
}

.due-date-badge {
    font-size: 0.8rem;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.todo-details {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
    padding-left: 2.5rem;
    display: none;
}

.todo-details.show {
    display: block;
}

.todo-main-info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.todo-meta-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 0.2rem;
}

/* 
========================================
   Filters & Stats
======================================== 
*/

.filters-container {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.filter-btn {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

.filter-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Tag Cloud - Floating Style */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 2rem;
    padding: 0.5rem;
    background: transparent; /* Removing the background as requested */
    border: none; /* Removing the border as requested */
}

.tag-cloud-title {
    width: 100%;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.tag-cloud-item {
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tag-cloud-item:hover, .tag-cloud-item.active {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* Tag Color coding logic in JS will apply these via style.borderColor and style.color */
.tag-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05); /* Default */
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
    transition: var(--transition-fast);
}

.stats-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 0 0.5rem;
}

.clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.clear-btn:hover {
    color: var(--danger-color);
    text-decoration: underline;
}

/* 
========================================
   Todo List & Items
======================================== 
*/

.todo-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    min-height: 150px;
}

.todo-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition-smooth);
    /* Animation when added */
    animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform-origin: center;
}

.todo-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(5px);
    border-color: rgba(255, 255, 255, 0.2);
}

.todo-item.completed {
    opacity: 0.6;
}

.todo-item.completed .todo-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.todo-item.completed .check-btn {
    background: var(--success-color);
    border-color: var(--success-color);
}

.todo-item.completed .check-btn i {
    opacity: 1;
    transform: scale(1);
}

/* Fall/Delete Animation */
.todo-item.fall {
    animation: fallDown 0.4s ease forwards;
}

.todo-item-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    overflow: hidden;
}

.check-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    background: transparent;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.check-btn i {
    color: white;
    font-size: 0.8rem;
    opacity: 0;
    transform: scale(0.5);
    transition: var(--transition-smooth);
}

.check-btn:hover {
    border-color: var(--success-color);
}

.todo-text {
    font-size: 1.05rem;
    color: var(--text-color);
    word-break: break-word;
    transition: var(--transition-fast);
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.3rem 0.5rem;
    border-radius: 8px;
    transition: var(--transition-fast);
}

.delete-btn:hover {
    color: var(--danger-color);
    background: rgba(244, 63, 94, 0.1);
}

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    animation: fadeIn 0.5s ease;
}

.empty-state i {
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.1);
}

/* 
========================================
   Animations
======================================== 
*/
@keyframes fadeInSlideUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(0.9); opacity: 0.5; }
}

@keyframes slideInRight {
    0% {
        opacity: 0;
        transform: translateX(-30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes fallDown {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 
========================================
   Responsive
======================================== 
*/
@media (max-width: 480px) {
    .app-container {
        padding: 1.5rem;
    }
    .logo h1 {
        font-size: 2rem;
    }
    .todo-submit-btn span {
        display: none;
    }
    .todo-submit-btn {
        padding: 0 1rem;
    }
    .logout-container {
        position: static;
        justify-content: center;
        margin-bottom: 1rem;
    }
}
/* 
========================================
   Task Modal & Subtasks (Phase 5)
======================================== 
*/

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #1e1b4b;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeInSlideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.admin-content {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.subtasks-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--card-border);
}

.subtask-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem 0;
}

.subtask-text {
    flex: 1;
    font-size: 0.95rem;
    cursor: pointer;
}

.subtask-item.completed .subtask-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.subtask-add-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.subtask-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    color: white;
    font-size: 0.9rem;
}

.subtask-progress {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

/* Clickable Task Area */
.todo-main-info {
    cursor: pointer;
}

.todo-main-info:hover .todo-text {
    color: var(--primary-color);
}
