/* ===================================================
   LAYOUT — Screens, Header, Sidebar, Main
   =================================================== */

/* --- Screen system --- */
.screen { display: none; }
.screen.active { display: flex; }

/* --- Setup & Login --- */
.login-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 0 24px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
}

#screen-login {
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    overflow-y: auto;
    position: relative;
}

/* Subtle gradient accent behind login */
#screen-login::before {
    content: '';
    position: absolute;
    top: -30%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.08) 0%, transparent 70%);
    pointer-events: none;
    border-radius: 50%;
}

.login-hero {
    text-align: center;
    margin-bottom: 36px;
    position: relative;
}

.login-icon {
    width: 88px; height: 88px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border-radius: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 20px;
    box-shadow:
        0 12px 32px rgba(var(--primary-rgb), 0.3),
        0 4px 12px rgba(var(--primary-rgb), 0.15);
    position: relative;
    transition: transform 0.3s ease;
}

.login-icon:hover {
    transform: translateY(-2px) scale(1.03);
}

/* Decorative ring behind icon */
.login-icon::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 28px;
    border: 2px dashed rgba(var(--primary-rgb), 0.2);
    animation: iconRingSpin 25s linear infinite;
}

@keyframes iconRingSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.login-title {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.75px;
    background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    margin-top: 6px;
    font-weight: 400;
}

/* Login & signup form card styling */
#screen-login .form-group input,
#screen-signup .form-group input {
    background: var(--bg-card);
    border-color: var(--border);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 15px;
    transition: var(--transition);
}

#screen-login .form-group input:focus,
#screen-signup .form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.1);
}

#screen-login .btn-primary,
#screen-signup .btn-primary {
    padding: 13px 20px;
    font-size: 15px;
    border-radius: var(--radius-md);
    margin-top: 6px;
}

.login-footer {
    text-align: center;
    margin-top: 32px;
}

.login-footer p {
    font-size: 12px;
    color: var(--text-tertiary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-weight: 500;
}

.login-switch {
    text-align: center;
    margin-top: 20px;
}

.login-switch p {
    font-size: 14px;
    color: var(--text-secondary);
}

.login-switch a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.login-switch a:hover {
    text-decoration: underline;
}

/* Signup screen specific */
#screen-signup {
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    overflow-y: auto;
    position: relative;
}

#screen-signup::before {
    content: '';
    position: absolute;
    top: -30%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.08) 0%, transparent 70%);
    pointer-events: none;
    border-radius: 50%;
}

.setup-logo p {
    color: var(--text-secondary);
    margin-top: 4px;
}

/* --- App Layout --- */
#screen-app {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* Header */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon {
    flex-shrink: 0;
}

.brand span { display: none; }

.mode-switcher {
    display: flex;
    background: var(--bg);
    border-radius: var(--radius-full);
    padding: 3px;
    gap: 2px;
}

.mode-btn {
    border: none;
    background: transparent;
    padding: 8px 18px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
}

.mode-btn span { display: none; }

.user-avatar {
    width: 34px; height: 34px;
    border-radius: var(--radius-full);
    background: var(--primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    border: 2px solid var(--primary);
}

.user-avatar img {
    width: 100%; height: 100%;
    object-fit: cover;
}

.user-avatar.large {
    width: 64px; height: 64px;
    font-size: 24px;
    border-width: 3px;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
}

.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-slow);
    z-index: -1;
}

.sidebar.open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
}

.sidebar-content {
    position: relative;
    width: var(--sidebar-w);
    height: 100%;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1;
    overflow-y: auto;
}

.sidebar-profile {
    padding: 24px 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.sidebar-profile .user-avatar {
    margin: 0 auto 12px;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 15px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
}

.sidebar-nav hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 12px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.sidebar-link:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-link.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }

.sidebar-link i { width: 20px; text-align: center; }
.text-urgent { color: var(--priority-urgent) !important; }
.text-high { color: var(--priority-high) !important; }
.text-overdue { color: var(--danger) !important; }

.sidebar-footer {
    padding: 8px;
    border-top: 1px solid var(--border);
}

/* --- Main Content --- */
.main-content {
    margin-top: var(--header-h);
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

/* Toolbar */
.toolbar {
    padding: 16px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg);
    position: sticky;
    top: var(--header-h);
    z-index: 10;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.view-title {
    font-size: 20px;
    font-weight: 700;
}

.task-count {
    font-size: 12px;
    color: var(--text-tertiary);
    background: var(--bg-hover);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.toolbar-right {
    display: flex;
    gap: 8px;
}

.search-box {
    flex: 1;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%; transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 13px;
}

.search-box input {
    width: 100%;
    padding: 9px 36px 9px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text);
    font-size: 13px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.btn-clear-search {
    position: absolute;
    right: 6px;
    top: 50%; transform: translateY(-50%);
    border: none;
    background: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
}

.sort-select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    min-width: 130px;
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Task list area */
.task-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 100px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* FAB */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px; height: 56px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
    z-index: 50;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(var(--primary-rgb), 0.5);
}

.fab:active { transform: scale(0.95); }
