@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Corporate HSL Color Palette */
    --primary: hsl(221, 83%, 53%);         /* Royal Blue */
    --primary-hover: hsl(221, 83%, 45%);
    --primary-light: hsl(221, 83%, 96%);
    --secondary: hsl(215, 16%, 47%);       /* Slate Gray */
    --secondary-hover: hsl(215, 16%, 37%);
    --success: hsl(142, 71%, 45%);         /* Emerald */
    --success-light: hsl(142, 71%, 95%);
    --danger: hsl(350, 89%, 60%);          /* Rose/Red */
    --danger-light: hsl(350, 89%, 96%);
    --warning: hsl(38, 92%, 50%);          /* Amber/Gold */
    --warning-light: hsl(38, 92%, 95%);
    --info: hsl(199, 89%, 48%);            /* Sky Blue */
    
    /* Backgrounds & Text */
    --bg-app: hsl(210, 40%, 98%);          /* Soft Cool White */
    --bg-card: hsl(0, 0%, 100%);           /* Pure White */
    --bg-sidebar: hsl(222, 47%, 11%);      /* Dark Slate Navy (slate-900) */
    --text-main: hsl(215, 47%, 15%);       /* Slate 900 */
    --text-muted: hsl(215, 16%, 47%);      /* Slate 500 */
    --text-light: hsl(210, 40%, 96%);
    
    /* Borders & Shadows */
    --border-color: hsl(214, 32%, 91%);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    --sidebar-width: 260px;
    --topbar-height: 70px;
}

/* Global Adjustments */
html, body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    font-size: 15px;
    min-height: 100%;
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: hsl(214, 32%, 80%);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: hsl(214, 32%, 70%);
}

/* Buttons */
.btn {
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}
.btn:focus, .btn:active:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2) !important;
    outline: none;
}
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.btn-success {
    background-color: var(--success);
    border-color: var(--success);
    color: #ffffff;
}
.btn-success:hover, .btn-success:focus {
    background-color: hsl(142, 71%, 38%);
    border-color: hsl(142, 71%, 38%);
    color: #ffffff;
    transform: translateY(-1px);
}
.btn-danger {
    background-color: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}
.btn-danger:hover, .btn-danger:focus {
    background-color: hsl(350, 89%, 50%);
    border-color: hsl(350, 89%, 50%);
    color: #ffffff;
    transform: translateY(-1px);
}
.btn-secondary {
    background-color: #ffffff;
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-secondary:hover, .btn-secondary:focus {
    background-color: hsl(210, 40%, 96%);
    border-color: var(--border-color);
    color: var(--text-main);
}

/* Card Overrides */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.card:hover {
    box-shadow: var(--shadow-md);
}
.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    font-weight: 700;
}
.card-body {
    padding: 1.5rem;
}

/* Inputs & Form Controls */
.form-control, .form-select {
    padding: 0.6rem 0.85rem;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    background-color: #ffffff;
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}
.form-label, label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

/* Table Enhancements */
.table {
    margin-bottom: 0;
    vertical-align: middle;
}
.table th, .table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.table thead {
    background-color: hsl(210, 40%, 96.5%);
}
.table thead th {
    font-weight: 700;
    font-size: 0.825rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}
.table-hover tbody tr:hover {
    background-color: hsl(210, 40%, 97.5%) !important;
}

/* Responsive Table Wrapper */
.table-responsive {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    margin-bottom: 1.5rem;
}

/* Badge Badges */
.badge {
    padding: 0.35em 0.65em;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50rem;
    text-transform: capitalize;
}

/* --- Sidebar Layout for Main Portal --- */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar styling */
.sidebar-wrapper {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: var(--transition);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffffff;
}

.sidebar-profile {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.12);
}

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}

.profile-info {
    overflow: hidden;
}

.profile-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: #ffffff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.profile-company {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5) !important;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
}

.menu-section-label {
    padding: 0.75rem 1.5rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.35);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.925rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-link i {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.5);
    transition: var(--transition);
}

.sidebar-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.04);
}

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

.sidebar-link.active {
    color: #ffffff;
    background-color: rgba(37, 99, 235, 0.12);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-link.active i {
    color: var(--primary);
}

.sidebar-submenu {
    list-style: none;
    padding-left: 3rem;
    margin-bottom: 0.5rem;
}

.sidebar-sublink {
    display: block;
    padding: 0.4rem 0;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--transition);
}

.sidebar-sublink:hover, .sidebar-sublink.active {
    color: #ffffff;
}

/* Main Layout Area */
.main-layout {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: var(--transition);
}

/* Topbar Header */
.top-header {
    height: var(--topbar-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background-color: hsl(210, 40%, 96%);
}

.top-header-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.top-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Content wrapper */
.page-content {
    flex: 1;
    padding: 2rem;
    background-color: var(--bg-app);
}

/* Sidebar overlay for mobile mobile drawer */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1030;
    transition: var(--transition);
}

/* Responsive sidebar layouts */
@media (max-width: 991.98px) {
    .sidebar-wrapper {
        transform: translateX(-100%);
    }
    .main-layout {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .top-header {
        padding: 0 1.25rem;
    }
    .page-content {
        padding: 1.25rem;
    }
    
    /* When drawer is open */
    .sidebar-open .sidebar-wrapper {
        transform: translateX(0);
    }
    .sidebar-open .sidebar-overlay {
        display: block;
    }

    /* Force tables to wrap content and fit the mobile screen width */
    .table-responsive,
    .page-content table:not(.table-inline) {
        width: 100% !important;
        max-width: 100% !important;
        display: table !important;
        table-layout: auto !important;
        border-radius: var(--radius-lg);
        border: 1px solid var(--border-color) !important;
        background-color: var(--bg-card);
        margin-bottom: 1.5rem;
    }

    /* Wrap column names (headers) and align columns */
    .page-content table th {
        white-space: normal !important;
        vertical-align: top;
        font-size: 0.8rem !important;
        padding: 0.6rem 0.5rem !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
    }

    /* Wrap table body cells */
    .page-content table td {
        white-space: normal !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
        font-size: 0.85rem !important;
        padding: 0.6rem 0.5rem !important;
    }

    /* Optimize action buttons inside tables for mobile layout */
    .page-content table td .btn {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.75rem !important;
        margin: 1px 0;
        display: inline-flex;
    }
}

/* --- Dashboard Enhancements --- */
.stat-card {
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    height: 100%;
}
.stat-card-border-primary { border-top: 4px solid var(--primary); }
.stat-card-border-info { border-top: 4px solid var(--info); }
.stat-card-border-success { border-top: 4px solid var(--success); }
.stat-card-border-danger { border-top: 4px solid var(--danger); }
.stat-card-border-warning { border-top: 4px solid var(--warning); }
.stat-card-border-dark { border-top: 4px solid var(--text-main); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}
.stat-icon-primary { background-color: var(--primary-light); color: var(--primary); }
.stat-icon-info { background-color: hsl(199, 89%, 95%); color: var(--info); }
.stat-icon-success { background-color: var(--success-light); color: var(--success); }
.stat-icon-danger { background-color: var(--danger-light); color: var(--danger); }
.stat-icon-warning { background-color: var(--warning-light); color: var(--warning); }
.stat-icon-dark { background-color: hsl(210, 40%, 92%); color: var(--text-main); }

.stat-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0;
    letter-spacing: -0.03em;
}

/* --- Premium Auth Views styling --- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, hsl(222, 47%, 11%) 0%, hsl(220, 40%, 20%) 100%);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}
.auth-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.12) 0%, rgba(0, 0, 0, 0) 70%);
    top: -200px;
    right: -200px;
}
.auth-page::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, rgba(0, 0, 0, 0) 70%);
    bottom: -200px;
    left: -200px;
}
.auth-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3), 0 10px 10px -5px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
    z-index: 10;
}
.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-brand i {
    font-size: 2.25rem;
    color: var(--primary);
    background: var(--primary-light);
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}
.auth-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}
.auth-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.auth-footer a:hover {
    text-decoration: underline;
}

/* Home page hero modification */
.home-hero {
    min-height: calc(100vh - var(--topbar-height) - 4rem);
    width: 100%;
    background: linear-gradient(135deg, hsl(222, 47%, 15%) 0%, hsl(222, 47%, 9%) 100%);
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem;
    box-shadow: var(--shadow-lg);
}

.home-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.15) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.2;
    pointer-events: none;
}

.home-hero .hero-content {
    color: #ffffff;
    max-width: 600px;
    z-index: 2;
    margin: auto 0;
}

.home-hero h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: #ffffff;
    margin-bottom: 1rem;
    line-height: 1.15;
}

.home-hero p {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.home-hero .support-pill {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    color: #ffffff;
    border-radius: 50rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.home-hero .support-pill i {
    color: var(--success);
}
@media (max-width: 768px) {
    .home-hero {
        padding: 1.5rem;
        min-height: calc(100vh - var(--topbar-height) - 2.5rem);
    }
}

/* Footer reset to prevent covering page content */
.footer {
    position: static !important;
    width: 100% !important;
    line-height: normal !important;
    white-space: normal !important;
    margin-top: auto !important;
    padding: 1.5rem 0 !important;
    background-color: var(--bg-card) !important;
    border-top: 1px solid var(--border-color) !important;
    box-shadow: none !important;
    z-index: 10;
}