/* 
  Global Styles & Layouts - Zyniti Leads 
*/

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--txt-main);
    line-height: 1.5;
    font-size: 14px;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Base Elements */
a {
    text-decoration: none;
    color: var(--clr-primary);
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--clr-primary-dark);
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

button {
    cursor: pointer;
    font-family: var(--font-family);
    border: none;
    background: none;
    outline: none;
}

input, select, textarea {
    font-family: var(--font-family);
    outline: none;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--txt-main);
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: 24px; margin-bottom: 16px; }
h2 { font-size: 20px; margin-bottom: 12px; }
h3 { font-size: 16px; margin-bottom: 8px; }

p {
    color: var(--txt-muted);
    margin-bottom: 16px;
}

/* Layout Architecture */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    height: 100%;
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-normal);
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.sidebar-logo .logo-icon {
    font-size: 28px;
    color: var(--clr-primary);
    min-width: 32px;
    display: flex;
    justify-content: center;
}

.sidebar-logo .logo-text {
    font-size: 20px;
    font-weight: 700;
    margin-left: 12px;
    color: var(--txt-main);
    white-space: nowrap;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-logo .logo-text {
    opacity: 0;
    pointer-events: none;
}

#btn-menu {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    color: var(--txt-muted);
    cursor: pointer;
    transition: color var(--transition-fast);
}

#btn-menu:hover {
    color: var(--clr-primary);
}

/* Sidebar Navigation */
.nav-list {
    padding: 16px 12px;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom Scrollbar for Sidebar */
.nav-list::-webkit-scrollbar {
    width: 6px;
}
.nav-list::-webkit-scrollbar-track {
    background: transparent;
}
.nav-list::-webkit-scrollbar-thumb {
    background-color: var(--border-light);
    border-radius: var(--radius-pill);
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    color: var(--txt-muted);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    position: relative;
    white-space: nowrap;
}

.nav-link i {
    font-size: 20px;
    min-width: 32px;
    display: flex;
    justify-content: center;
    transition: color var(--transition-fast);
}

.nav-link .link-name {
    margin-left: 12px;
    font-weight: 500;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .nav-link .link-name {
    opacity: 0;
    pointer-events: none;
}

.nav-link:hover {
    background-color: var(--bg-hover);
    color: var(--clr-primary);
}

.nav-link:hover i {
    color: var(--clr-primary);
}

.nav-link.active {
    background-color: var(--clr-primary);
    color: var(--txt-light);
    box-shadow: 0 4px 10px rgba(73, 104, 177, 0.3);
}

.nav-link.active i {
    color: var(--txt-light);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--border-light);
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-search {
    display: flex;
    align-items: center;
    background-color: var(--bg-main);
    border-radius: var(--radius-pill);
    padding: 8px 16px;
    width: 350px;
    border: 1px solid var(--border-light);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.header-search:focus-within {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(73, 104, 177, 0.1);
}

.header-search i {
    color: var(--txt-muted);
    font-size: 18px;
    margin-right: 12px;
}

.header-search input {
    background: transparent;
    border: none;
    width: 100%;
    color: var(--txt-main);
    font-size: 14px;
}

.header-search input::placeholder {
    color: var(--txt-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

.user-profile:hover {
    background-color: var(--bg-hover);
}

.user-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--txt-main);
}

.user-role {
    font-size: 12px;
    color: var(--txt-muted);
}

/* Dynamic View Container */
.view-container {
    padding: 32px;
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
}

/* Page Headers (inside views) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    margin-bottom: 4px;
}

.page-subtitle {
    margin-bottom: 0;
}

.page-actions {
    display: flex;
    gap: 12px;
}

/* Responsive */
@media (max-width: 992px) {
    .header-search {
        width: 250px;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
        width: var(--sidebar-width);
    }
    
    #btn-menu {
        display: block; /* Typically handled via a separate mobile toggle */
    }
}

@media (max-width: 768px) {
    .header-search {
        display: none;
    }
    
    .view-container {
        padding: 16px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .user-info {
        display: none;
    }
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
    opacity: 0;
    transition: opacity var(--transition-normal);
}
.mobile-overlay.active {
    display: block;
    opacity: 1;
}

@media (max-width: 992px) {
    .header-search { display: none; }
    #mobile-menu-btn { display: block !important; margin-right: 16px; color: var(--txt-main); }
    .top-header { justify-content: space-between; padding: 0 20px; }
    .header-actions { margin-left: auto; }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 100;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
        width: 260px;
    }
    
    #btn-menu {
        display: none; /* Hide internal sidebar toggle on mobile */
    }
}

@media (max-width: 768px) {
    .view-container {
        padding: 16px;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .page-actions {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }
    .user-info {
        display: none;
    }
    .card-header {
        flex-direction: column;
        align-items: stretch;
    }
    .card-header select, .card-header .header-search {
        width: 100% !important;
    }
}