/* css/layout.css - Login, Sidebar, Main Layout, and Global UI Components */

/* --- 0. GLOBAL RESET --- */
* { box-sizing: border-box; }

/* --- 1. LOGIN VIEW --- */
#login-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-bottom: 80px;
}

.brand-header {
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.brand-logo-img { width: 90px; height: auto; object-fit: contain; }

.login-card {
    background: var(--bg-card);
    width: 460px;
    max-width: 95%;
    padding: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
    text-align: left;
}

.login-error-banner {
    display: none;
    color: #DC2626;
    background-color: #FEF2F2;
    padding: 10px;
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.5;
    font-weight: 500;
}

.login-links { margin-top: 25px; text-align: center; font-size: 0.9rem; }
.link { color: var(--primary); text-decoration: none; cursor: pointer; font-weight: 500; }
.link:hover { text-decoration: underline; }

.login-footer {
    margin-top: auto;
    width: 100%;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    background: #fff;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- 2. APP LAYOUT STRUCTURE --- */
#app-layout { 
    display: none; 
    height: 100vh; 
    flex-direction: column; 
    overflow: hidden; /* Global Scroll Lock */
}

#top-bar {
    height: 60px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

/* --- 3. SIDEBAR --- */
.sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    z-index: 50;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 25px 24px;
    border-bottom: 1px solid #F1F5F9;
    flex-shrink: 0;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

#nav-menu {
    flex: 1;
    overflow-y: auto;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav-item:hover, .nav-item.active { 
    background-color: var(--primary-light); 
    color: var(--primary); 
    font-weight: 600;
}

.sidebar-footer {
    padding: 15px; 
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
    margin-top: auto;
}

.user-profile-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    transition: all 0.2s ease;
}
.user-profile-card:hover {
    background: #fff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 0.85rem; font-weight: 600; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: #64748b; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

.user-actions {
    color: #94a3b8;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}
.user-actions:hover { background: #fee2e2; color: #ef4444; }

/* MAIN CONTENT - FIXED SCROLLING */
.main { 
    flex: 1; 
    padding: 32px; 
    overflow-y: auto; 
    overflow-x: hidden; /* Stops Main Horizontal Scroll */
    max-width: 100%;
    background-color: var(--bg-body); 
    display: flex;
    flex-direction: column;
}

#main-container { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    min-height: 0; 
    max-width: 100%;
}

/* --- 4. WORK CENTER TOOLBAR --- */
.task-module {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    max-width: 100%;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}
.task-title-section h1 { margin: 0; font-size: 1.8rem; color: #1e293b; }
.task-title-section p { margin: 5px 0 0 0; color: #64748b; }

.task-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    padding: 10px 15px;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 10px;
    border-radius: 8px 8px 0 0;
    border: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.toolbar-section { display: flex; align-items: center; gap: 10px; }
.view-toggles { display: flex; gap: 5px; }

.view-btn {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #4b5563;
    transition: all 0.2s;
}
.view-btn:hover { background: #f3f4f6; }
.view-btn.active { background: #3b82f6; color: white; border-color: #2563eb; }

/* Icon Toolbar Styles */
.action-group { display: flex; align-items: center; gap: 4px; }

.btn-icon-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: white;
    border: 1px solid #d1d5db;
    color: #64748b; 
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon-sm:hover { background-color: #f1f5f9; color: #1e293b; border-color: #9ca3af; }
.btn-icon-sm.active { background-color: #eff6ff; color: #2563eb; border-color: #60a5fa; }

/* Filters */
.task-filters { display: flex; align-items: center; gap: 10px; }
.filter-select { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.85rem; min-width: 150px; background-color: white; }

/* --- 5. RIGHT SIDE DRAWER --- */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: none;
    justify-content: flex-end;
}

.drawer-content {
    width: 500px;
    max-width: 90%;
    height: 100%;
    background: white;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    padding: 0;
    animation: slideInRight 0.3s ease-out;
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }

.drawer-header { padding: 15px 20px; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }

/* --- 6. UTILITIES --- */
.badge { padding: 4px 8px; border-radius: 4px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.badge.project { background: #dbeafe; color: #1e40af; }
.badge.task { background: #f3f4f6; color: #374151; }
.badge.customer { background: #ede9fe; color: #5b21b6; }
.badge.subtask { background: #e0e7ff; color: #3730a3; }
.status-pill { display: inline-block; padding: 2px 8px; border-radius: 12px; background: #dcfce7; color: #166534; font-size: 0.75rem; font-weight: 600; margin-left: 8px; }

.drawer-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
    background: #f8fafc;
    padding: 15px;
    border-radius: 8px;
}

.meta-item label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 3px;
    font-weight: 600;
}

.meta-item div {
    font-size: 0.9rem;
    color: #0f172a;
    font-weight: 500;
}

/* LIST VIEW CONTAINER - FIXING SCROLL */
#task-main-content { 
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden; /* Force Hide X Scroll */
    width: 100%;
    border: 1px solid #e5e7eb;
    border-top: none;
    background: white;
    border-radius: 0 0 8px 8px;
    position: relative;
}
.task-content { overflow-x: hidden; }

/* --- 7. BUTTONS --- */
button { font-family: inherit; }
.task-actions { display: flex; gap: 10px; }

.btn-primary {
    background-color: #3b82f6; 
    color: white; 
    border: none; 
    padding: 8px 16px; 
    border-radius: 6px; 
    font-weight: 500; 
    font-size: 0.9rem; 
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: background 0.2s;
}
.btn-primary:hover { background-color: #2563eb; }

.btn-secondary {
    background-color: white;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover { background-color: #f9fafb; border-color: #9ca3af; }

.btn-icon {
    background: white;
    border: 1px solid #d1d5db;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    color: #4b5563;
}
.btn-icon:hover { background-color: #f3f4f6; }

/* --- 8. KANBAN BOARD (FIXED & RESTORED) --- */
.kanban-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.kanban-filters {
    padding: 10px 20px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: #555;
}

.kanban-board {
    display: flex;
    gap: 15px;
    padding: 20px;
    overflow-x: auto; /* Enable horizontal scroll here */
    height: 100%;
    align-items: flex-start;
}

.kanban-col {
    min-width: 280px; /* Fixed width for columns */
    width: 280px;
    background-color: #f1f5f9;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    max-height: 100%;
    border: 1px solid #e2e8f0;
    flex-shrink: 0; /* CRITICAL: Prevents columns from shrinking */
}

.kanban-header {
    padding: 12px 15px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #334155;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    border-radius: 8px 8px 0 0;
}

.kanban-body {
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 50px;
}

.kanban-card {
    background: white;
    padding: 12px;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
    cursor: grab;
    transition: all 0.2s;
}
.kanban-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    border-color: #cbd5e1;
}

.k-title { font-weight: 600; font-size: 0.9rem; color: #1e293b; margin-bottom: 8px; line-height: 1.4; }
.k-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; color: #64748b; }

/* --- 9. LIST VIEW OVERFLOW FIX --- */
.list-view-wrapper, .task-list-container {
    overflow-x: hidden; /* Specifically hide X scroll for lists */
    width: 100%;
    max-width: 100%;
}