/* ===========================================
   Levor Connect — Brand Design System
   Based on connect.levor.io + KenionLine HR
   =========================================== */

@import url('https://fonts.googleapis.com/css2?family=Alef:wght@400;700&display=swap');

:root {
    /* Primary — Levor Teal (connect.levor.io) */
    --primary-color: #1FB298;
    --primary-dark: #148F77;
    --primary-text: #117A66;       /* WCAG AA on white: 5.3:1 */
    --primary-light: #E8F7F5;
    --primary-rgb: 31, 178, 152;

    /* Sidebar — Dark Teal */
    --sidebar-bg: #032E26;
    --sidebar-hover: #045A4B;
    --sidebar-active: #1FB298;
    --sidebar-width: 250px;

    /* Accent — Royal Purple (shared by connect + HR) */
    --accent-color: #8360c3;
    --accent-gradient: linear-gradient(135deg, #8360c3 0%, #1FB298 100%);
    --royal-gradient: linear-gradient(135deg, #8360c3 0%, #2ebf91 100%);

    /* Semantic */
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;

    /* Text */
    --text-primary: #343A38;
    --text-muted: #6c757d;

    /* Backgrounds */
    --body-bg: #f0f9f5;
    --card-bg: #ffffff;

    /* Shared */
    --border-radius: 20px;
    --border-radius-sm: 12px;
    --border-radius-lg: 25px;
    --box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    --box-shadow-hover: 0 12px 40px rgba(31, 178, 152, 0.15);
    --transition: all 0.3s ease;

    /* Card gradients (stat cards) */
    --gradient-teal: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gradient-purple: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-orange: linear-gradient(135deg, #ff9a56 0%, #ff6b35 100%);
    --gradient-pink: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-blue: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-coral: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

/* ===========================================
   TYPOGRAPHY
   =========================================== */
body {
    font-family: 'Alef', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-primary);
    background: linear-gradient(135deg, #f0f9f5 0%, #f8f9fa 50%, #f0f6ff 100%);
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 80%, rgba(31, 178, 152, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(131, 96, 195, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(46, 191, 145, 0.02) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
}

/* ===========================================
   SIDEBAR
   =========================================== */
#sidebar-wrapper {
    transition: margin 0.3s ease-out;
    background: linear-gradient(180deg, #032E26 0%, #045A4B 100%) !important;
    border-left: 1px solid rgba(31, 178, 152, 0.15);
}

#sidebar-wrapper .sidebar-heading {
    font-size: 1.1rem;
    border-bottom-color: rgba(31, 178, 152, 0.2) !important;
}

#sidebar-wrapper .list-group-item {
    transition: var(--transition);
    background: transparent !important;
    border: none !important;
    color: rgba(255, 255, 255, 0.8) !important;
    font-weight: 500;
    position: relative;
}

#sidebar-wrapper .list-group-item::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--sidebar-active);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 0 3px 3px 0;
}

#sidebar-wrapper .list-group-item:hover {
    background: rgba(31, 178, 152, 0.25) !important;
    color: white !important;
    padding-right: 25px;
}

#sidebar-wrapper .list-group-item:hover::before {
    opacity: 1;
}

#sidebar-wrapper .list-group-item.active {
    background: rgba(31, 178, 152, 0.25) !important;
    color: white !important;
}

#sidebar-wrapper .list-group-item.active::before {
    opacity: 1;
}

#sidebar-wrapper .list-group-item i {
    color: var(--sidebar-active);
    width: 20px;
    text-align: center;
}

/* Sidebar bottom section */
#sidebar-wrapper .border-top {
    border-top-color: rgba(31, 178, 152, 0.2) !important;
}

/* ===========================================
   PAGE WRAPPER
   =========================================== */
#page-content-wrapper {
    min-width: 0;
    width: 100%;
}

/* ===========================================
   CARDS
   =========================================== */
.card {
    border: 1px solid var(--primary-light);
    border-radius: var(--border-radius);
    transition: var(--transition);
    box-shadow: var(--box-shadow);
    overflow: hidden;
    position: relative;
}

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

.card-header {
    background: linear-gradient(135deg, #f8fffe 0%, #f0f9f5 100%);
    border-bottom: 1px solid var(--primary-light);
    font-weight: 700;
}

/* Stat cards with color bands */
.card.bg-primary,
.card.bg-success,
.card.bg-info,
.card.bg-warning,
.card.bg-secondary {
    border: none;
    border-radius: var(--border-radius);
}

.card.bg-primary {
    background: var(--gradient-teal) !important;
}

.card.bg-success {
    background: var(--gradient-purple) !important;
}

.card.bg-info {
    background: var(--gradient-blue) !important;
}

.card.bg-warning {
    background: var(--gradient-orange) !important;
    color: white !important;
}

.card.bg-secondary {
    background: var(--accent-gradient) !important;
}

/* ===========================================
   DASHBOARD BANNER
   =========================================== */
.dashboard-banner,
.page-banner {
    background: var(--royal-gradient);
    border-radius: var(--border-radius-lg);
    padding: 35px 40px;
    color: white;
    position: relative;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.dashboard-banner::before,
.page-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(45deg,
        transparent,
        transparent 20px,
        rgba(255, 255, 255, 0.04) 20px,
        rgba(255, 255, 255, 0.04) 40px);
    animation: moveStripes 20s linear infinite;
}

@keyframes moveStripes {
    0% { transform: translateX(-100px) translateY(-100px); }
    100% { transform: translateX(100px) translateY(100px); }
}

.dashboard-banner h2,
.dashboard-banner h4,
.page-banner h2,
.page-banner h4 {
    position: relative;
    z-index: 2;
}

.dashboard-banner p,
.page-banner p {
    position: relative;
    z-index: 2;
    opacity: 0.9;
}

/* ===========================================
   TABLES
   =========================================== */
.table th {
    font-weight: 700;
    background: linear-gradient(135deg, #f8fffe 0%, #f0f9f5 100%);
    color: var(--text-primary);
}

.table-hover tbody tr:hover {
    background-color: rgba(31, 178, 152, 0.06);
}

.table {
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

/* ===========================================
   BUTTONS
   =========================================== */
.btn {
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    transition: var(--transition);
    padding: 0.5rem 1.2rem;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--accent-gradient);
    border: none;
    box-shadow: 0 4px 15px rgba(31, 178, 152, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #7050b3 0%, #178F7A 100%);
    box-shadow: 0 6px 20px rgba(31, 178, 152, 0.4);
}

.btn-primary:active,
.btn-primary:focus {
    background: linear-gradient(135deg, #6040a3 0%, #14806d 100%);
    box-shadow: 0 0 0 0.25rem rgba(31, 178, 152, 0.25);
}

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

.btn-outline-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
    border: none;
}

/* ===========================================
   BADGES
   =========================================== */
.badge {
    font-weight: 600;
    padding: 0.5em 0.9em;
    border-radius: 8px;
}

.badge.bg-primary {
    background: var(--primary-dark) !important;
}

.badge.bg-info {
    background: #0a98b0 !important; /* darker cyan for white text: 4.6:1 */
}

/* ===========================================
   FORMS
   =========================================== */
.form-control {
    border-radius: var(--border-radius-sm);
    padding: 0.65rem 1rem;
    border: 2px solid #e9ecef;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 0.2rem rgba(23, 143, 122, 0.3);
}

.form-select {
    border-radius: var(--border-radius-sm);
    border: 2px solid #e9ecef;
}

.form-select:focus {
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 0.2rem rgba(23, 143, 122, 0.3);
}

.input-group-text {
    border-radius: 12px 0 0 12px;
    background: var(--primary-light);
    border: 2px solid #e9ecef;
    color: var(--primary-text);
    font-weight: 600;
}

/* ===========================================
   ALERTS
   =========================================== */
.alert {
    border-radius: var(--border-radius-sm);
    border: none;
    font-weight: 500;
}

.alert-success {
    background: linear-gradient(135deg, #d1e7dd 0%, #e8f5e9 100%);
    color: #0f5132;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #fde8e8 100%);
    color: #842029;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #fff8e1 100%);
    color: #664d03;
}

.alert-info {
    background: linear-gradient(135deg, #cff4fc 0%, #e0f7fa 100%);
    color: #055160;
}

/* ===========================================
   DEVICE CARDS
   =========================================== */
.device-card {
    transition: var(--transition);
    border-radius: var(--border-radius);
}

.device-card.online {
    border-color: var(--success-color);
    border-width: 2px;
}

.device-card.offline {
    border-color: #dee2e6;
}

.device-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(31, 178, 152, 0.15);
}

/* ===========================================
   STATUS INDICATORS
   =========================================== */
.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.online {
    background-color: var(--success-color);
    animation: pulse 2s infinite;
}

.status-indicator.offline {
    background-color: var(--text-muted);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

/* ===========================================
   PRICING CARDS
   =========================================== */
.pricing-card {
    transition: var(--transition);
    border-radius: var(--border-radius);
}

.pricing-card:hover {
    transform: scale(1.02);
}

.pricing-card.recommended {
    border: 2px solid var(--primary-color);
    box-shadow: 0 10px 40px rgba(31, 178, 152, 0.2);
}

/* ===========================================
   NAVBAR (top bar)
   =========================================== */
.navbar {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
}

.navbar .nav-link {
    color: var(--text-primary) !important;
    font-weight: 500;
}

.navbar .nav-link:hover {
    color: var(--primary-color) !important;
}

/* ===========================================
   FOOTER
   =========================================== */
footer {
    margin-top: auto;
    background: transparent;
    color: var(--text-muted);
}

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

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

/* ===========================================
   MODAL
   =========================================== */
.modal-content {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-header {
    background: linear-gradient(135deg, #f8fffe 0%, #f0f9f5 100%);
    border-bottom: 1px solid var(--primary-light);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

/* ===========================================
   SCROLLBAR
   =========================================== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--primary-light);
}

::-webkit-scrollbar-thumb {
    background: rgba(31, 178, 152, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(31, 178, 152, 0.5);
}

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 991.98px) {
    #sidebar-wrapper {
        margin-right: -250px;
    }

    #sidebar-wrapper.toggled {
        margin-right: 0;
    }
}

/* ===========================================
   PRINT
   =========================================== */
@media print {
    #sidebar-wrapper,
    .navbar,
    .btn,
    footer {
        display: none !important;
    }

    #page-content-wrapper {
        margin: 0;
        padding: 0;
    }
}

/* ===========================================
   RTL SPECIFIC
   =========================================== */
[dir="rtl"] .input-group-text {
    border-radius: 0 12px 12px 0;
}

[dir="rtl"] .input-group .form-control {
    border-radius: 12px 0 0 12px;
}

/* ===========================================
   LOADING SPINNER
   =========================================== */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

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

/* ===========================================
   UTILITY — Selection Color
   =========================================== */
::selection {
    background: rgba(31, 178, 152, 0.2);
    color: var(--text-primary);
}

/* ===========================================
   PAGE TITLE (h1/h2 in main content)
   =========================================== */
.page-title,
h1.text-primary,
h2.text-primary {
    color: var(--primary-text) !important;
}

/* Override Bootstrap text-primary for WCAG */
.text-primary {
    color: var(--primary-text) !important;
}

/* ===========================================
   LINKS
   =========================================== */
a {
    color: var(--primary-text);
    transition: color 0.2s ease;
}

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

/* ===========================================
   DISABLED STATES
   =========================================== */
.btn:disabled,
.btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ===========================================
   STAT CARD TEXT — override Bootstrap opacity
   =========================================== */
.card.bg-primary .opacity-50,
.card.bg-success .opacity-50,
.card.bg-info .opacity-50,
.card.bg-secondary .opacity-50,
.card.bg-warning .opacity-50 {
    opacity: 0.3 !important; /* decorative icons only */
}

.card.bg-primary .opacity-75,
.card.bg-success .opacity-75,
.card.bg-info .opacity-75,
.card.bg-secondary .opacity-75,
.card.bg-warning .opacity-75,
.card.bg-primary .text-white-50,
.card.bg-success .text-white-50,
.card.bg-info .text-white-50 {
    opacity: 1 !important;
    color: rgba(255, 255, 255, 0.92) !important;
}

/* Warning card: dark text stays readable */
.card.bg-warning .text-dark.opacity-75 {
    opacity: 1 !important;
    color: #343A38 !important;
}

/* ===========================================
   GRADIENT ICON TEXT SHADOW (Alerts/Analytics)
   =========================================== */
.summary-icon,
[class*="stat-icon"] {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ===========================================
   FOCUS-VISIBLE (WCAG 2.1 AA)
   =========================================== */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible,
.list-group-item:focus-visible,
.nav-link:focus-visible,
a:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: none;
}

/* Skip to content link (hidden until focused) */
.skip-to-content {
    position: absolute;
    top: -100%;
    right: 0;
    z-index: 10000;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 0 0 0 var(--border-radius-sm);
    font-weight: 700;
    text-decoration: none;
    transition: top 0.2s;
}

.skip-to-content:focus {
    top: 0;
    color: white;
}

/* ===========================================
   BUTTON LOADING STATE
   =========================================== */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.75;
}

.btn-loading .btn-text {
    visibility: hidden;
}

.btn-loading .btn-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: inline-block !important;
}

.btn-spinner {
    display: none;
    width: 1.2rem;
    height: 1.2rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    border-top-color: white;
    animation: btnSpin 0.6s linear infinite;
}

@keyframes btnSpin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===========================================
   REDUCED MOTION (Accessibility)
   =========================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .dashboard-banner::before,
    .page-banner::before,
    .auth-header::before {
        animation: none !important;
    }
}

/* ===========================================
   RTL PAGINATION FIX
   =========================================== */
[dir="rtl"] .pagination .page-link .fa-chevron-left {
    transform: scaleX(-1);
}

[dir="rtl"] .pagination .page-link .fa-chevron-right {
    transform: scaleX(-1);
}

/* ===========================================
   NAV-TABS — Brand Styling (global)
   Eliminates embedded <style> in individual views
   =========================================== */
.nav-tabs {
    border-bottom: 2px solid var(--primary-light);
}

.nav-tabs .nav-link {
    border: none;
    color: var(--text-muted);
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
}

.nav-tabs .nav-link:hover:not(.active) {
    color: var(--primary-color);
    border-bottom-color: #dee2e6;
    background: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--primary-text);
    border-bottom: 3px solid var(--primary-color);
    background: transparent;
}

/* ===========================================
   EMPTY STATE — Reusable pattern
   =========================================== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state i,
.empty-state .empty-icon {
    font-size: 3.5rem;
    color: #c4d6d2;
    margin-bottom: 1rem;
    display: block;
}

.empty-state h5 {
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* ===========================================
   TABLE IMPROVEMENTS — Sticky headers, mobile
   =========================================== */
.table-sticky thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.table-responsive {
    border-radius: var(--border-radius-sm);
}

/* Horizontal scroll fade indicator for tables */
.table-responsive::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0.9), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

/* ===========================================
   BORDER-START CARDS — Brand colors for
   Organization, Admin ticket stats, etc.
   =========================================== */
.border-primary {
    border-color: var(--primary-color) !important;
}

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

.border-info {
    border-color: #0a98b0 !important;
}

/* ===========================================
   BREADCRUMBS — Brand styling
   =========================================== */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 0.5rem;
}

.breadcrumb-item a {
    color: var(--primary-text);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb-item a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--text-muted);
}

.breadcrumb-item + .breadcrumb-item::before {
    color: #ccc;
}

/* ===========================================
   PAGE HEADER — Consistent across views
   =========================================== */
.page-header-bar {
    background: var(--royal-gradient);
    border-radius: var(--border-radius-lg);
    padding: 30px 35px;
    color: white;
    position: relative;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.page-header-bar::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(45deg,
        transparent,
        transparent 20px,
        rgba(255, 255, 255, 0.04) 20px,
        rgba(255, 255, 255, 0.04) 40px);
    animation: moveStripes 20s linear infinite;
}

.page-header-bar h2,
.page-header-bar h3,
.page-header-bar p {
    position: relative;
    z-index: 2;
}
