/* Praxis Web - Theme Variables */
/* Premium Navy Blue to match splash screen branding */
:root,
[data-theme="dark"] {
    --bg-primary: #1e2a3a;
    /* Splash screen navy blue */
    --bg-secondary: #2a3547;
    /* Slightly lighter navy */
    --bg-card: #2a3547;
    --bg-sidebar: #161f2d;
    /* Darker navy for sidebar */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-gold: #c9a962;
    /* Gold accent from logo */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #3d4a5c;
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] {
    --bg-primary: #f0f4f8;
    /* Slightly darker for better contrast */
    --bg-secondary: #e2e8f0;
    --bg-card: #ffffff;
    --bg-sidebar: #1e2a3a;
    /* Keep sidebar dark for consistency with brand */
    --text-primary: #1a202c;
    /* Darker for better readability */
    --text-secondary: #2d3748;
    /* Much darker for better contrast */
    --text-muted: #4a5568;
    /* Darker, still subtle but readable */
    --accent: #2563eb;
    /* Slightly darker blue for visibility */
    --accent-hover: #1d4ed8;
    --accent-gold: #b8860b;
    /* Darker gold for light mode */
    --success: #059669;
    /* Darker green */
    --warning: #d97706;
    /* Darker orange */
    --danger: #dc2626;
    /* Darker red */
    --border: #94a3b8;
    /* Darker border for visibility */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

p,
li {
    color: var(--text-secondary);
    line-height: 1.6;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
}

/* Layout */
.page {
    padding: 2rem;
}

.content {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Only apply hover lift effect to small stat cards, not large content panels */
.card.stat-card:hover,
.card.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.card-header {
    background: rgba(59, 130, 246, 0.1);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
}

.card-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

.card-title {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* Stat Cards */
.card.bg-primary,
.card.bg-success,
.card.bg-info,
.card.bg-secondary,
.card.bg-danger,
.card.bg-warning {
    border: none;
    background: linear-gradient(135deg, var(--accent) 0%, #1d4ed8 100%) !important;
}

.card.bg-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%) !important;
}

.card.bg-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%) !important;
}

.card.bg-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%) !important;
}

.card.bg-info {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%) !important;
}

.card.bg-secondary {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: rgba(59, 130, 246, 0.1);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table td {
    color: var(--text-secondary);
}

.table tbody tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

.table-danger {
    background: rgba(239, 68, 68, 0.15) !important;
}

.table-sm th,
.table-sm td {
    padding: 0.5rem 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-light {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-light:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-link {
    background: transparent;
    color: var(--accent);
    padding: 0;
}

/* Forms */
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    text-transform: capitalize;
}

.bg-success {
    background: var(--success) !important;
    color: white !important;
}

.bg-warning {
    background: var(--warning) !important;
    color: #1e293b !important;
}

.bg-danger {
    background: var(--danger) !important;
    color: white !important;
}

.bg-info {
    background: #06b6d4 !important;
    color: white !important;
}

/* Navigation Sidebar - Solid dark navy matching splash screen */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 250px;
    background: #1e2a3a;
    /* Exact splash screen navy blue */
    border-right: 1px solid rgba(50, 70, 100, 0.3);
    padding: 1.5rem;
    overflow-y: auto;
}

/* Subtle particle dot overlay - matching splash screen texture */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 15% 12%, rgba(100, 140, 180, 0.15) 2px, transparent 2px),
        radial-gradient(circle at 82% 8%, rgba(80, 120, 160, 0.12) 2px, transparent 2px),
        radial-gradient(circle at 28% 38%, rgba(90, 130, 170, 0.1) 3px, transparent 3px),
        radial-gradient(circle at 72% 28%, rgba(100, 140, 180, 0.12) 2px, transparent 2px),
        radial-gradient(circle at 12% 62%, rgba(80, 120, 160, 0.15) 2px, transparent 2px),
        radial-gradient(circle at 88% 52%, rgba(90, 130, 170, 0.1) 2px, transparent 2px),
        radial-gradient(circle at 42% 78%, rgba(100, 145, 180, 0.12) 3px, transparent 3px),
        radial-gradient(circle at 58% 68%, rgba(80, 120, 160, 0.08) 2px, transparent 2px),
        radial-gradient(circle at 25% 88%, rgba(90, 130, 170, 0.12) 2px, transparent 2px),
        radial-gradient(circle at 75% 92%, rgba(100, 140, 180, 0.1) 2px, transparent 2px);
    background-size: 100% 100%;
    pointer-events: none;
    z-index: 0;
}

.sidebar>* {
    position: relative;
    z-index: 1;
}

.sidebar .logo {
    margin-bottom: 0.5rem;
    text-align: center;
}

.sidebar .logo-link {
    text-decoration: none;
    display: block;
}

.sidebar .logo-link:hover {
    text-decoration: none;
}

.sidebar .logo-img {
    max-width: 180px;
    height: auto;
}

.sidebar .tagline {
    font-size: 0.75rem;
    color: #e2e8f0;
    /* Near-white for WCAG AA on dark sidebar */
    margin-bottom: 2rem;
    text-align: center;
}

.sidebar .nav-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar .nav-items li {
    margin-bottom: 0.25rem;
}

.sidebar .nav-items a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #f1f5f9 !important;
    /* Near-white text for WCAG AA contrast on dark sidebar - !important overrides theme */
    border-radius: 8px;
    transition: all 0.2s;
    text-decoration: none;
}

.sidebar .nav-items a:hover,
.sidebar .nav-items a.active {
    background: rgba(59, 130, 246, 0.15);
    color: #ffffff;
    /* White on hover - always visible */
}

.sidebar .nav-items a.active {
    background: var(--accent);
    color: white;
}

/* Main Content Area */
.main-content {
    margin-left: 250px;
    min-height: 100vh;
    padding: 2rem;
}

/* Grid */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: -0.75rem;
}

.col-md-3,
.col-md-6,
.col-md-12 {
    padding: 0.75rem;
}

.col-md-3 {
    width: 25%;
}

.col-md-6 {
    width: 50%;
}

.col-md-12 {
    width: 100%;
}

/* Hide mobile elements by default (desktop) */
.hamburger {
    display: none;
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 1024px) {

    .col-md-3,
    .col-md-6 {
        width: 100%;
    }

    .sidebar {
        position: fixed;
        left: -250px;
        transition: left 0.3s ease;
        z-index: 1000;
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    .hamburger {
        display: flex;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1001;
        width: 40px;
        height: 40px;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 8px;
        cursor: pointer;
    }

    .hamburger span {
        width: 20px;
        height: 2px;
        background: var(--text-primary);
        transition: all 0.3s;
    }

    .hamburger.open span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .hamburger.open span:nth-child(2) {
        opacity: 0;
    }

    .hamburger.open span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.open {
        display: block;
    }
}

.mb-4 {
    margin-bottom: 1.5rem;
}

/* Text utilities */
.text-white {
    color: white !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* Loading state */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--border);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    color: var(--text-primary);
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* Error handling */
#blazor-error-ui {
    background: var(--danger);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: white;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    border-radius: var(--border-radius);
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* Validation */
.valid.modified:not([type=checkbox]) {
    outline: 2px solid var(--success);
}

.invalid {
    outline: 2px solid var(--danger);
}

.validation-message {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

code {
    background: var(--bg-secondary);
    color: var(--accent);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.875em;
}

/* Skeleton Loading Animation */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-secondary) 25%,
            var(--bg-card) 50%,
            var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-card {
    height: 120px;
    border-radius: var(--border-radius);
}

/* Button Micro-animations */
.btn {
    transition: all 0.2s ease;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn-outline-primary:hover {
    background: var(--accent);
    color: white;
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: white;
}

/* Card Hover Transitions */
.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* Modal Animation */
.modal.fade.show {
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-dialog {
    animation: modalSlideIn 0.25s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
    }

    to {
        transform: translateY(0);
    }
}

/* Toast Notification Styles */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: toastSlideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-warning {
    background: var(--warning);
    color: #1e293b;
}

.toast-info {
    background: var(--accent);
}

/* Smooth Table Row Hover */
.table tbody tr {
    transition: background-color 0.15s ease;
}

/* Focus States for Accessibility */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Responsive Improvements */
@media (max-width: 576px) {
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .card-body {
        padding: 1rem;
    }
}

/* ========================================
   Mobile Responsiveness Enhancements
   ======================================== */

/* 768px and below - tablets and large phones */
@media (max-width: 768px) {

    /* Tables: Horizontal scroll wrapper */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 600px;
    }

    /* Smaller table cells on mobile */
    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }

    /* Admin tabs: wrap on mobile */
    .admin-tabs {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        padding-bottom: 0.5rem;
    }

    /* Table responsive wrapper for horizontal scroll */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive .admin-table {
        min-width: 600px;
    }

    .admin-tabs .tab {
        flex: 1 1 auto;
        min-width: 70px;
        text-align: center;
        padding: 0.5rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Admin page padding */
    .admin-page {
        padding: 1rem !important;
    }

    /* Admin section responsive */
    .admin-section {
        padding: 1rem;
        border-radius: 0.75rem;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    /* Admin table: minimum width for horizontal scroll */
    .admin-table {
        min-width: 700px;
    }

    .admin-table th,
    .admin-table td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    /* Touch-friendly button sizes (min 44px tap target per WCAG) */
    .btn,
    button {
        min-height: 44px;
        min-width: 44px;
    }

    /* Stack action buttons vertically */
    .action-buttons,
    .actions {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    /* Modal improvements */
    .modal-dialog {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
    }

    .modal-content {
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    .modal-header,
    .modal-footer {
        padding: 0.75rem 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    /* Fix page padding on mobile */
    .page,
    .content,
    .main-content {
        padding: 1rem;
    }

    /* Cards stack full width */
    .card {
        margin-bottom: 0.75rem;
    }

    /* Form controls: full width */
    .form-control,
    .form-select {
        width: 100%;
    }
}

/* 480px and below - phones */
@media (max-width: 480px) {
    h1 {
        font-size: 1.25rem;
    }

    h2 {
        font-size: 1.125rem;
    }

    /* Reduce table minimum width for very small screens */
    .table {
        min-width: 400px;
    }

    /* Hide less important columns on very small screens */
    .table .hide-mobile {
        display: none;
    }

    /* Compact badges */
    .badge {
        font-size: 0.625rem;
        padding: 0.15rem 0.4rem;
    }

    /* Stack modal buttons */
    .modal-footer {
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* Connection Health Status Indicators */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.connection-status.healthy {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.connection-status.degraded {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.connection-status.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.connection-status.unknown {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

.connection-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* Toast Notification Position Fix for Mobile */
@media (max-width: 576px) {
    .toast-container {
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 20px;
    }

    .toast {
        margin: 0;
    }
}