/* =============================================================
   AtlasOne ERP Platform - Core Stylesheet
   ============================================================= */

:root {
    --color-primary:    #0F172A;
    --color-secondary:  #1E293B;
    --color-accent:     #2563EB;
    --color-accent-hover:#1D4ED8;
    --color-sidebar-w:  260px;
    --color-card-bg:    #FFFFFF;
    --color-body-bg:    #F1F5F9;
    --color-border:     #E2E8F0;
    --color-text:       #1E293B;
    --color-text-muted: #64748B;
    --color-success:    #10B981;
    --color-warning:    #F59E0B;
    --color-danger:     #EF4444;
    --color-info:       #3B82F6;
    --shadow-sm:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md:        0 4px 6px -1px rgba(0,0,0,0.10), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg:        0 10px 15px -3px rgba(0,0,0,0.10), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius:           0.5rem;
    --radius-lg:        0.75rem;
    --transition:       all 0.2s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-body-bg);
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); text-decoration: underline; }

/* ---- Layout Wrapper ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--color-sidebar-w);
    min-height: 100vh;
    background: var(--color-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: 80px;
    background: #F1F5F9;
}

.sidebar-brand .brand-logo {
    width: 36px;
    height: 36px;
    background: var(--color-accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

/* Sidebar horizontal logo (full: globe + ATLASONE text) */
.brand-logo-horizontal {
    height: 66px;
    width: auto;
    object-fit: contain;
    display: block;
    transition: var(--transition);
}

/* Sidebar icon-only logo shown when collapsed */
.brand-logo-icon {
    height: 36px;
    width: 36px;
    object-fit: contain;
    display: none;
    flex-shrink: 0;
}

/* When sidebar is collapsed: hide horizontal, show icon */
.sidebar.collapsed .brand-logo-horizontal { display: none; }
.sidebar.collapsed .brand-logo-icon       { display: block; }

/* Auth page logo image */
.auth-logo {
    width: auto;
    height: auto;
    background: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.auth-logo-img {
    width: auto;
    height: 130px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.sidebar-brand .brand-name {
    margin-left: 0.75rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: 0.025em;
    white-space: nowrap;
    transition: var(--transition);
}

/* brand-name span removed - logo image carries the text */

/* Nav */
.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.nav-section-label {
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.35);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 0.5rem 1rem;
}

.nav-item { position: relative; }

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1.25rem;
    color: rgba(255,255,255,0.65);
    transition: var(--transition);
    cursor: pointer;
    white-space: nowrap;
    border-left: 3px solid transparent;
    text-decoration: none !important;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
    border-left-color: rgba(255,255,255,0.3);
}

.nav-link.active {
    color: #fff;
    background: rgba(37,99,235,0.25);
    border-left-color: var(--color-accent);
}

.nav-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link .link-text {
    margin-left: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar.collapsed .link-text { opacity: 0; width: 0; overflow: hidden; }

/* ---- Folder / collapsible nav group ---- */
.nav-folder-toggle {
    display: flex;
    align-items: center;
}
.nav-folder-arrow {
    margin-left: auto;
    font-size: .65rem;
    color: rgba(255,255,255,0.35);
    transition: transform .2s ease;
    flex-shrink: 0;
}
.nav-folder-arrow.open,
.nav-folder-toggle[aria-expanded="true"] .nav-folder-arrow {
    transform: rotate(90deg);
    color: rgba(255,255,255,0.65);
}
.nav-submenu {
    background: rgba(0,0,0,0.15);
    border-left: 2px solid rgba(255,255,255,0.08);
    margin-left: 1.25rem;
    margin-right: .5rem;
    border-radius: 0 0 .35rem .35rem;
}
.nav-sublink {
    display: flex;
    align-items: center;
    padding: .5rem 1rem;
    color: rgba(255,255,255,0.55);
    font-size: .82rem;
    font-weight: 500;
    text-decoration: none !important;
    transition: var(--transition);
    border-left: 2px solid transparent;
    margin-left: -2px;
    border-radius: .25rem;
}
.nav-sublink:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
    border-left-color: rgba(255,255,255,0.3);
}
.nav-sublink.active {
    color: #fff;
    background: rgba(37,99,235,0.25);
    border-left-color: var(--color-accent);
}
.nav-sublink i {
    font-size: .82rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.nav-sublink .link-text {
    margin-left: .6rem;
}

/* Second-level subfolder (pure CSS toggle, no nested Bootstrap collapse) */
.nav-subfolder {
    /* no overflow:hidden - lets children render freely */
}
.nav-subfolder-hd {
    cursor: pointer;
    user-select: none;
}
.nav-subfolder-arrow {
    font-size: .58rem;
    color: rgba(255,255,255,0.25);
    transition: transform .2s ease;
    flex-shrink: 0;
}
.nav-subfolder.open .nav-subfolder-arrow {
    transform: rotate(90deg);
    color: rgba(255,255,255,0.55);
}
.nav-subfolder-body {
    display: none;
    background: rgba(0,0,0,0.12);
    border-left: 2px solid rgba(255,255,255,0.06);
    margin-left: .75rem;
}
.nav-subfolder.open .nav-subfolder-body {
    display: block;
}
.nav-subsublink {
    display: flex;
    align-items: center;
    padding: .38rem .85rem;
    color: rgba(255,255,255,0.45);
    font-size: .78rem;
    font-weight: 400;
    text-decoration: none !important;
    transition: var(--transition);
    white-space: normal;
    word-break: break-word;
}
.nav-subsublink:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
    text-decoration: none !important;
}
.nav-subsublink.active {
    color: #fff;
    background: rgba(37,99,235,0.2);
}
.nav-subsublink i {
    font-size: .72rem;
    width: 15px;
    text-align: center;
    flex-shrink: 0;
    margin-right: .5rem;
}
.nav-subsublink .link-text {
    line-height: 1.3;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-card {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: var(--radius);
    background: rgba(255,255,255,0.06);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.user-info {
    margin-left: 0.65rem;
    overflow: hidden;
    transition: var(--transition);
}

.sidebar.collapsed .user-info { opacity: 0; width: 0; }

.user-name {
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: rgba(255,255,255,0.45);
    font-size: 0.7rem;
    white-space: nowrap;
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-content {
    margin-left: var(--color-sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: var(--transition);
}

.sidebar.collapsed ~ .main-content { margin-left: 70px; }

/* ---- Top Nav ---- */
.topnav {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

.topnav-left { display: flex; align-items: center; gap: 1rem; }

.btn-sidebar-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-sidebar-toggle:hover {
    background: var(--color-body-bg);
    color: var(--color-text);
}

.page-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.topnav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topnav-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: transparent;
    cursor: pointer;
    transition: var(--transition);
    color: var(--color-text);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
}

.topnav-user-btn:hover {
    background: var(--color-body-bg);
    text-decoration: none;
    color: var(--color-text);
}

.topnav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}
/* ---- Universal circular photo mask ---- */
.avatar-circle {
    border-radius: 50% !important;
    object-fit: cover;
    display: inline-block;
    flex-shrink: 0;
}

.topnav-avatar-img {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px;
    max-width: 28px;
    border-radius: 50% !important;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.5);
    flex-shrink: 0;
    display: block;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.4);
}

/* ---- Page Content ---- */
.page-content {
    padding: 1.75rem;
    flex: 1;
}

/* ---- Page Header ---- */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 0.25rem;
}

.page-header .breadcrumb {
    background: none;
    padding: 0;
    margin: 0;
    font-size: 0.8rem;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card-header h5, .card-header h6 {
    margin: 0;
    font-weight: 600;
    color: var(--color-text);
}

.card-body { padding: 1.25rem; }

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.stat-icon.icon-blue   { background: #EFF6FF; color: #2563EB; }
.stat-icon.icon-green  { background: #F0FDF4; color: #10B981; }
.stat-icon.icon-orange { background: #FFF7ED; color: #F59E0B; }
.stat-icon.icon-purple { background: #F5F3FF; color: #7C3AED; }
.stat-icon.icon-red    { background: #FEF2F2; color: #EF4444; }

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* ---- Quick Tile ---- */
.quick-tile {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.25rem;
    text-align: center;
    transition: var(--transition);
    display: block;
    text-decoration: none !important;
    color: var(--color-text) !important;
}

.quick-tile:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-accent);
    transform: translateY(-2px);
}

.quick-tile i {
    font-size: 2rem;
    color: var(--color-accent);
    margin-bottom: 0.75rem;
    display: block;
}

.quick-tile span {
    font-size: 0.875rem;
    font-weight: 600;
}

/* ============================================================
   TABLES
   ============================================================ */
.atlas-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.atlas-table th {
    background: #F8FAFC;
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.atlas-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    vertical-align: middle;
}

.atlas-table tbody tr:hover { background: #F8FAFC; }
.atlas-table tbody tr:last-child td { border-bottom: none; }

/* Override ASP.NET GridView default styles */
.atlas-table th a { color: var(--color-text-muted) !important; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none !important;
    line-height: 1.4;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}
.btn-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); color: #fff; }

.btn-secondary {
    background: #fff;
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-body-bg); }

.btn-success  { background: var(--color-success);  color: #fff; border-color: var(--color-success); }
.btn-danger   { background: var(--color-danger);   color: #fff; border-color: var(--color-danger); }
.btn-warning  { background: var(--color-warning);  color: #fff; border-color: var(--color-warning); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
}

.form-control, .form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--color-text);
    background: #fff;
    transition: var(--transition);
    outline: none;
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-control.is-invalid { border-color: var(--color-danger); }

.invalid-feedback {
    display: block;
    color: var(--color-danger);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-success  { background: #D1FAE5; color: #065F46; }
.badge-danger   { background: #FEE2E2; color: #991B1B; }
.badge-warning  { background: #FEF3C7; color: #92400E; }
.badge-info     { background: #DBEAFE; color: #1E40AF; }
.badge-secondary{ background: #F1F5F9; color: #475569; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-danger  { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ============================================================
   AUTH PAGES (Login / Register)
   ============================================================ */
.auth-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 50%, #263555 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
}

.auth-header {
    background: #ffffff;
    padding: 2rem 2rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}

.auth-logo {
    margin-bottom: 1.25rem;
}

.auth-logo {    
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.auth-header h2 {
    color: var(--color-primary);
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.auth-header p {
    color: var(--color-text-muted);
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
}

.auth-body { padding: 2rem; }

.auth-footer {
    text-align: center;
    padding: 1rem 2rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-content { overflow: hidden; border-radius: .3rem; }
.modal-header {
    background: var(--color-primary);
    color: #fff;
    border-radius: 0;
    padding: 1rem 1.25rem;
}

.modal-header .modal-title { color: #fff; font-size: 1rem; font-weight: 600; }
.modal-header .close { color: rgba(255,255,255,0.7); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 999;
    }
    .sidebar-overlay.active { display: block; }
}

@media (max-width: 576px) {
    .page-content { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.4rem; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted  { color: var(--color-text-muted) !important; }
.text-accent { color: var(--color-accent) !important; }
.fw-600      { font-weight: 600; }
.fw-700      { font-weight: 700; }
.rounded-lg  { border-radius: var(--radius-lg); }
.gap-2       { gap: 0.5rem; }
.d-flex      { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
