/* ============================================
   Melita Field Service Management - App Styles
   ============================================ */

:root {
    /* Melita Brand Colors */
    --melita-primary: #19421f;         /* Dark forest green - brand-1 */
    --melita-secondary: #cdff58;       /* Lime green - brand-2 */
    --melita-light: #fafafa;           /* Off-white */
    --melita-dark: #141e23;            /* Dark blue-gray */
    --melita-neutral: #222;            /* Neutral dark */

    /* Layout Variables */
    --sidebar-width: 250px;
    --header-height: 60px;

    /* Semantic Colors */
    --primary-color: var(--melita-primary);
    --primary-light: #1f5426;
    --primary-dark: #133319;
    --secondary-color: var(--melita-secondary);

    /* Sidebar Colors */
    --sidebar-bg: var(--melita-dark);
    --sidebar-hover: rgba(205, 255, 88, 0.1);          /* Subtle lime tint on hover */
    --sidebar-active: var(--melita-secondary);          /* Lime green for active */
    --sidebar-active-text: var(--melita-dark);          /* Dark text on lime */

    /* Background Colors */
    --body-bg: var(--melita-light);
}

html, body {
    font-family: 'Aeonik Pro', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    height: 100%;
    margin: 0;
    background-color: var(--body-bg);
}

/* Aeonik Pro Font - Melita Brand Typography */
@font-face {
    font-family: 'Aeonik Pro';
    src: url('https://cdn.prod.website-files.com/6739eaef98fc4326f5be40f5/6749d0064bfc1e9a97d8f2fc_AeonikPro-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Aeonik Pro';
    src: url('https://cdn.prod.website-files.com/6739eaef98fc4326f5be40f5/6749d006563a09ff2e99b94f_AeonikPro-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Aeonik Pro';
    src: url('https://cdn.prod.website-files.com/6739eaef98fc4326f5be40f5/6749d006b9da5c001eea4e0c_AeonikPro-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ============================================
   Page Layout
   ============================================ */

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-content {
    display: flex;
    flex: 1;
}

/* ============================================
   Sidebar Navigation
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand .brand-logo {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    font-weight: 700;
    font-size: 1.1rem;
    padding: 6px;
}

.sidebar-brand .brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-brand .brand-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 0.5rem;
}

.nav-section-header {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.4);
    padding: 0.75rem 1.25rem 0.5rem;
    margin-top: 0.5rem;
}

.nav-item {
    padding: 0 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.15s ease;
    font-size: 0.9rem;
}

.nav-link:hover {
    color: var(--melita-secondary);
    background: var(--sidebar-hover);
}

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

.nav-link i {
    font-size: 1.1rem;
    width: 24px;
    margin-right: 0.75rem;
    text-align: center;
}

/* ============================================
   Main Content Area
   ============================================ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================
   Top Header
   ============================================ */

.top-header {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #212529;
    margin: 0;
}

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

.header-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.header-icon-btn:hover {
    background: #f8f9fa;
    color: #212529;
}

.header-icon-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.65rem;
}

.user-dropdown {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.user-dropdown:hover {
    background: #f8f9fa;
}

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

.user-info {
    line-height: 1.2;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #212529;
}

.user-role {
    font-size: 0.75rem;
    color: #6c757d;
}

/* ============================================
   Content Area
   ============================================ */

.content-wrapper {
    flex: 1;
    padding: 1.5rem;
    background: var(--body-bg);
}

.content-header {
    margin-bottom: 1.5rem;
}

.content-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #212529;
    margin: 0 0 0.25rem;
}

.content-header .breadcrumb {
    margin: 0;
    padding: 0;
    background: transparent;
    font-size: 0.85rem;
}

/* ============================================
   Cards
   ============================================ */

.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.12);
    background: #fff;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* Stat Cards */
.stat-card {
    border-radius: 10px;
    padding: 1.25rem;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -20%;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.3;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* Melita branded stat cards */
.stat-card.bg-primary { background: linear-gradient(135deg, var(--melita-primary) 0%, #133319 100%); }
.stat-card.bg-success { background: linear-gradient(135deg, #198754 0%, #146c43 100%); }
.stat-card.bg-warning { background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%); color: #212529; }
.stat-card.bg-info { background: linear-gradient(135deg, var(--melita-secondary) 0%, #b8e64d 100%); color: var(--melita-dark); }
.stat-card.bg-danger { background: linear-gradient(135deg, #dc3545 0%, #bb2d3b 100%); }
.stat-card.bg-melita { background: linear-gradient(135deg, var(--melita-primary) 0%, #1f5426 100%); }
.stat-card.bg-melita-accent { background: linear-gradient(135deg, var(--melita-secondary) 0%, #b8e64d 100%); color: var(--melita-dark); }

/* ============================================
   Tables
   ============================================ */

.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #495057;
    padding: 0.875rem 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #eee;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--melita-primary);
    border-color: var(--melita-primary);
}

.btn-primary:hover {
    background: #133319;
    border-color: #133319;
}

.btn-secondary {
    background: var(--melita-secondary);
    border-color: var(--melita-secondary);
    color: var(--melita-dark);
}

.btn-secondary:hover {
    background: #b8e64d;
    border-color: #b8e64d;
    color: var(--melita-dark);
}

.btn-outline-primary {
    color: var(--melita-primary);
    border-color: var(--melita-primary);
}

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

/* ============================================
   Forms
   ============================================ */

.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid #ced4da;
    padding: 0.5rem 0.875rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--melita-primary);
    box-shadow: 0 0 0 0.2rem rgba(25, 66, 31, 0.15);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: #495057;
}

/* ============================================
   Badges
   ============================================ */

.badge {
    font-weight: 500;
    padding: 0.4em 0.65em;
    border-radius: 4px;
}

.status-badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
}

/* ============================================
   Alerts
   ============================================ */

.alert {
    border: none;
    border-radius: 8px;
    border-left: 4px solid;
}

.alert-info { border-left-color: #0dcaf0; background: #cff4fc; }
.alert-success { border-left-color: #198754; background: #d1e7dd; }
.alert-warning { border-left-color: #ffc107; background: #fff3cd; }
.alert-danger { border-left-color: #dc3545; background: #f8d7da; }

/* ============================================
   Validation
   ============================================ */

.valid.modified:not([type=checkbox]) {
    outline: none;
    border-color: #198754;
}

.invalid {
    outline: none;
    border-color: #dc3545;
}

.validation-message {
    color: #dc3545;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* ============================================
   Links
   ============================================ */

a {
    color: var(--melita-primary);
    text-decoration: none;
}

a:hover {
    color: #133319;
    text-decoration: underline;
}

/* ============================================
   Blazor Error UI
   ============================================ */

#blazor-error-ui {
    background: #dc3545;
    color: #fff;
    bottom: 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    left: 0;
    padding: 1rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.75rem;
}

.blazor-error-boundary {
    background: #dc3545;
    padding: 1rem 1.5rem;
    color: white;
    border-radius: 8px;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ============================================
   Mobile Navigation
   ============================================ */

.hamburger-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #212529;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    margin-right: 0.75rem;
    font-size: 1.5rem;
    transition: background 0.15s ease;
}

.hamburger-btn:hover {
    background: #f8f9fa;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    .main-content {
        margin-left: 0;
    }

    .page-title {
        font-size: 1rem;
    }

    .content-wrapper {
        padding: 1rem;
    }
}

/* Extra small devices */
@media (max-width: 575.98px) {
    .top-header {
        padding: 0 0.75rem;
    }

    .header-right {
        gap: 0.5rem;
    }

    .user-dropdown {
        padding: 0.5rem;
    }

    .content-wrapper {
        padding: 0.75rem;
    }
}

/* ============================================
   Utilities
   ============================================ */

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

.hover-shadow:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ============================================
   Melita Brand Utilities
   ============================================ */

.bg-melita-primary {
    background-color: var(--melita-primary) !important;
}

.bg-melita-secondary {
    background-color: var(--melita-secondary) !important;
}

.bg-melita-dark {
    background-color: var(--melita-dark) !important;
}

.bg-melita-light {
    background-color: var(--melita-light) !important;
}

.text-melita-primary {
    color: var(--melita-primary) !important;
}

.text-melita-secondary {
    color: var(--melita-secondary) !important;
}

.text-melita-dark {
    color: var(--melita-dark) !important;
}

.border-melita-primary {
    border-color: var(--melita-primary) !important;
}

.border-melita-secondary {
    border-color: var(--melita-secondary) !important;
}

/* Melita Brand Logo Placeholder */
.brand-logo-melita {
    background: var(--melita-primary);
    color: var(--melita-secondary);
}

/* Sidebar Brand Accent */
.sidebar-brand .brand-logo {
    background: var(--melita-primary);
    border: 2px solid var(--melita-secondary);
}

/* Sidebar active states with brand colors */
.sidebar .nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-text);
    font-weight: 600;
}

/* Tab and Pill navigation with brand colors */
.nav-pills .nav-link.active {
    background-color: var(--melita-primary);
}

.nav-tabs .nav-link {
    color: #495057;
    background: transparent;
    border: 1px solid transparent;
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
}

.nav-tabs .nav-link:hover {
    color: var(--melita-primary);
    border-color: #e9ecef #e9ecef #dee2e6;
}

.nav-tabs .nav-link.active {
    color: var(--melita-primary);
    background-color: #fff;
    border-color: #dee2e6 #dee2e6 #fff;
    font-weight: 500;
}

/* Progress bar with brand color */
.progress-bar.bg-melita {
    background-color: var(--melita-primary) !important;
}

/* Badge variants */
.badge.bg-melita {
    background-color: var(--melita-primary) !important;
}

.badge.bg-melita-secondary {
    background-color: var(--melita-secondary) !important;
    color: var(--melita-dark) !important;
}

/* Melita branded alert */
.alert-melita {
    border: none;
    border-radius: 8px;
    border-left: 4px solid var(--melita-primary);
    background: rgba(25, 66, 31, 0.1);
    color: var(--melita-dark);
}

/* Focus rings with brand color */
.form-check-input:checked {
    background-color: var(--melita-primary);
    border-color: var(--melita-primary);
}

.form-check-input:focus {
    border-color: var(--melita-primary);
    box-shadow: 0 0 0 0.2rem rgba(25, 66, 31, 0.25);
}

/* Dropdown active state */
.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--melita-primary);
}

/* Pagination active state */
.page-item.active .page-link {
    background-color: var(--melita-primary);
    border-color: var(--melita-primary);
}

.page-link {
    color: var(--melita-primary);
}

.page-link:hover {
    color: #133319;
}

/* Link hover underline utility */
.link-hover-underline {
    text-decoration: none;
}

.link-hover-underline:hover {
    text-decoration: underline;
}

/* ============================================
   Sortable Table Headers & Column Filters
   ============================================ */

.table-sortable .sortable-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.table-sortable .sortable-header:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    cursor: default;
}

.column-filter-wrapper {
    position: relative;
    display: inline-block;
    z-index: 1050;
}

.column-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1050;
    min-width: 220px;
    max-width: 300px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    margin-top: 4px;
}

.column-filter-dropdown .filter-options {
    max-height: 200px;
    overflow-y: auto;
}

.column-filter-dropdown .dropdown-item {
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
}

.column-filter-dropdown .dropdown-item:hover {
    background-color: #f8f9fa;
}

.filter-open .card-body,
.filter-open .table-responsive {
    overflow: visible !important;
}

.filter-open .card-body {
    min-height: 320px;
}
