/* Modern Beautiful Design */
html {
    min-height: 100%;
    position: relative;
}

body {
    background-color: #5468d4; /* Fallback color */
    background-image: url('../images/GlobalBackground.png');
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed;
    background-size: cover;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Main content wrapper - pushes footer to bottom */
.container {
    flex: 1 0 auto;
    padding: 2rem 0;
}

.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 2rem;
    background: white;
}

.card-header {
    background: linear-gradient(135deg, #5468d4 0%, #5f3d85 100%);
    color: white;
    font-weight: 600;
    border-radius: 15px 15px 0 0 !important;
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
}

.card-body {
    padding: 1.5rem;
}

/* VERY DARK VISIBLE BORDERS */
.form-control, .form-select, input[type="text"], input[type="password"], textarea, select {
    border: 3px solid #000000 !important;
    background-color: #ffffff !important;
    border-radius: 8px;
    padding: 0.75rem;
}

.form-control:focus, .form-select:focus {
    border-color: #5468d4 !important;
    box-shadow: 0 0 0 0.25rem rgba(84, 104, 212, 0.25) !important;
}

.btn {
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #5468d4 0%, #5f3d85 100%);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(84, 104, 212, 0.4);
}

.btn-secondary {
    background: #6c757d;
    border: none;
}

.btn-info {
    background: #128299;
    border: none;
}

.btn-warning {
    background: #ffc107;
    border: none;
    color: #000;
}

.btn-danger {
    background: #dc3545;
    border: none;
}

.btn-dark {
    background: #343a40;
    border: none;
}

/* Tables */
.table {
    background: white;
    border-radius: 10px;
    overflow: hidden;
}

.table thead th {
    background: linear-gradient(135deg, #5468d4 0%, #5f3d85 100%);
    color: white;
    border: none;
    font-weight: 600;
    padding: 1rem;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.table thead th:hover {
    opacity: 0.9;
}

.table thead th::after {
    content: ' ⇅';
    font-size: 0.8em;
    opacity: 0.6;
}

.table thead th.sort-asc::after {
    content: ' ↑';
    opacity: 1;
}

.table thead th.sort-desc::after {
    content: ' ↓';
    opacity: 1;
}

.table tbody tr {
    transition: background 0.2s ease;
}

.table tbody tr:hover {
    background-color: #f8f9ff;
}

.table td {
    padding: 1rem;
    vertical-align: middle;
}

/* Modals */
.modal-content {
    border-radius: 15px;
    border: none;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header {
    background: linear-gradient(135deg, #5468d4 0%, #5f3d85 100%);
    color: white;
    border-radius: 15px 15px 0 0;
    padding: 1.25rem 1.5rem;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #dee2e6;
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
}

/* Footer - sticky to bottom when content is short */
footer {
    padding: 0;
    font-size: 0.75rem;
    flex-shrink: 0;
    margin-top: auto;
}

footer img {
    height: 30px; /* Increased by 50% from 20px */
}

/* Cookie Consent Banner */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    z-index: 9999;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.3);
}

.cookie-consent a {
    color: #1a8a6e;
    text-decoration: underline;
}

/* Powered by bar */
.powered-by-bar {
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Sticky Header */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
}

.powered-by-bar {
    position: sticky;
    top: 36px; /* Adjusted for ultra-compact navbar */
    z-index: 1029;
}

/* Provider info bar for clients */
.provider-info-bar {
    position: sticky;
    top: 54px; /* Adjusted: navbar (36px) + powered-by (18px) */
    z-index: 1028;
    padding: 4px 0;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.provider-info-bar img {
    height: 75px; /* Increased by 50% from 50px */
}

/* Legacy class name support */
.clinic-info-bar {
    position: sticky;
    top: 54px;
    z-index: 1028;
}

/* Smaller/more compact navbar */
.navbar {
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
}

.navbar .navbar-brand img {
    height: 68px; /* Increased by 50% from 45px */
}

.navbar .navbar-brand {
    padding-top: 0;
    padding-bottom: 0;
}

.navbar .nav-link {
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
    font-size: 0.85rem;
}

/* hdrEEG tag - fixed top right corner */
.hdrEEG-tag-container {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 9999;
}

/* When inside container, don't need positioning on the image */
.hdrEEG-tag-container .hdrEEG-tag-fixed {
    position: static;
}

/* Standalone usage (login page, etc.) - needs its own positioning */
.hdrEEG-tag-fixed {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 9999;
    opacity: 0.95;
    height: 63px; /* Increased by 50% from 42px */
}

/* Data activity LED - tiny indicator on hdrEEG tag (left bottom with spacing) */
.data-led {
    position: absolute;
    bottom: 8px;
    left: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #333;
    box-shadow: inset 0 0 2px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
}

.data-led.active {
    background-color: #00ff88;
    box-shadow: 0 0 6px 2px rgba(0, 255, 136, 0.6), inset 0 0 2px rgba(255,255,255,0.3);
    animation: ledPulse 0.8s ease-in-out;
}

@keyframes ledPulse {
    0% {
        opacity: 1;
        box-shadow: 0 0 8px 3px rgba(0, 255, 136, 0.8), inset 0 0 2px rgba(255,255,255,0.3);
    }
    50% {
        opacity: 0.6;
        box-shadow: 0 0 4px 1px rgba(0, 255, 136, 0.4), inset 0 0 2px rgba(255,255,255,0.2);
    }
    100% {
        opacity: 1;
        box-shadow: 0 0 6px 2px rgba(0, 255, 136, 0.6), inset 0 0 2px rgba(255,255,255,0.3);
    }
}

/* Navigation improvements */
.navbar .nav-link {
    transition: all 0.3s ease;
    border-radius: 8px;
    margin: 0 2px;
}

.navbar .nav-link:hover {
    background: rgba(255,255,255,0.1);
}

.navbar .nav-link.active {
    background: rgba(255,255,255,0.2);
}

/* Login page specific */
.min-vh-100 {
    display: flex;
    align-items: center;
}

/* TEST PORTAL Banner - fixed position */
.test-server-banner {
    position: fixed;
    top: 63px;
    right: 0;
    z-index: 9998;
    padding: 2px 12px;
    font-size: 0.9rem;
    font-weight: bold;
    color: #CC44FF;
    background: rgba(0, 0, 0, 0.7);
    border-bottom-left-radius: 6px;
}

/* Ensure right navbar items don't overlap with hdrEEG tag */
.navbar-nav.ms-auto {
    padding-right: 70px; /* Space for hdrEEG tag (63px + padding) */
}

/* Responsive - extra large screens (menu collapses at xxl/1400px) */
@media (max-width: 1399px) and (min-width: 1200px) {
    /* XL screens near collapse: smaller hdrEEG tag */
    .hdrEEG-tag-fixed {
        height: 55px !important;
    }
    .hdrEEG-tag-container .hdrEEG-tag-fixed {
        height: 55px !important;
    }
    .navbar-nav.ms-auto {
        padding-right: 60px; /* Adjusted for smaller tag */
    }
    .test-server-banner {
        top: 55px;
        font-size: 0.8rem;
    }
}

/* Responsive - large screens (collapsed menu at 1200px and below) */
@media (max-width: 1199px) and (min-width: 993px) {
    /* Large screens: smaller hdrEEG tag for collapsed menu */
    .hdrEEG-tag-fixed {
        height: 50px !important;
    }
    .hdrEEG-tag-container .hdrEEG-tag-fixed {
        height: 50px !important;
    }
    .navbar-nav.ms-auto {
        padding-right: 55px;
    }
    .test-server-banner {
        top: 50px;
        font-size: 0.8rem;
    }
}

/* Responsive - medium screens (collapsed menu) */
@media (max-width: 992px) and (min-width: 769px) {
    /* Medium screens: smaller hdrEEG tag */
    .hdrEEG-tag-fixed {
        height: 45px !important;
    }
    .hdrEEG-tag-container .hdrEEG-tag-fixed {
        height: 45px !important;
    }
    .navbar-nav.ms-auto {
        padding-right: 50px; /* Collapsed menu needs less padding */
    }
    .test-server-banner {
        top: 45px;
        font-size: 0.75rem;
    }
}

/* Responsive - mobile */
@media (max-width: 768px) {
    .table {
        font-size: 0.875rem;
    }
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    /* Mobile: smaller hdrEEG tag to avoid overlap with menu */
    .hdrEEG-tag-fixed {
        height: 42px !important;
    }
    .hdrEEG-tag-container .hdrEEG-tag-fixed {
        height: 42px !important;
    }
    /* Mobile: move navbar toggler down to avoid hdrEEG tag */
    .navbar-toggler {
        margin-top: 10px;
    }
    /* Mobile: remove extra padding from collapsed navbar */
    .navbar-nav.ms-auto {
        padding-right: 50px;
    }
    /* Mobile: adjust test portal banner position */
    .test-server-banner {
        top: 42px;
        font-size: 0.75rem;
        padding: 1px 8px;
    }
    /* Mobile: smaller data LED */
    .data-led {
        bottom: 4px;
        left: 4px;
        width: 6px;
        height: 6px;
    }
}

/* Modal styling - let Bootstrap handle z-index and display */

/* Scrollbar for tables with more than 10 rows */
.table-responsive {
    max-height: 600px;
    overflow-y: auto;
}

/* Custom scrollbar styling */
.table-responsive::-webkit-scrollbar {
    width: 10px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #5468d4 0%, #5f3d85 100%);
    border-radius: 5px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5f3d85 0%, #5468d4 100%);
}

/* Tom Select styling to match site theme */
.ts-wrapper.single .ts-control {
    border: 3px solid #000000 !important;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    min-height: calc(1.5em + 1.5rem + 6px);
}

.ts-wrapper.single .ts-control:focus,
.ts-wrapper.single.focus .ts-control {
    border-color: #5468d4 !important;
    box-shadow: 0 0 0 0.25rem rgba(84, 104, 212, 0.25) !important;
}

.ts-dropdown {
    border: 2px solid #000000;
    border-radius: 8px;
    margin-top: 2px;
}

.ts-dropdown .option {
    padding: 0.5rem 0.75rem;
}

.ts-dropdown .option.active {
    background: linear-gradient(135deg, #5468d4 0%, #5f3d85 100%);
    color: white;
}

/* =============================================================================
 * NEUROFEEDBACK SMOOTH TRANSITIONS
 * Ensures all NF display elements transition smoothly without flickering
 * =============================================================================
 */

/* Progress bars - smooth width and color transitions */
.progress-bar {
    transition: width 0.3s ease-out, background-color 0.3s ease-out, opacity 0.3s ease-out;
}

/* Dimming overlay - smooth opacity for video brightness */
#dimmingOverlay {
    transition: opacity 0.15s ease-out !important;
}

/* Brightness bars - smooth width and color transitions */
#brightnessBar,
#fullscreenBrightnessBar {
    transition: width 0.3s ease-out, background-color 0.3s ease-out;
}

/* Range window and value markers - already have transitions but ensure consistency */
#rangeWindow {
    transition: left 0.15s ease, width 0.15s ease, background 0.15s ease;
}

#currentValueMarker {
    transition: left 0.1s ease-out;
}

/* Badge status indicators - smooth color transitions */
.badge {
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Stream status badge - smooth transitions */
#streamStatusBadge {
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Cards and panels - smooth background transitions */
.card-body {
    transition: background 0.3s ease;
}

/* Audio frequency visualizer elements */
.frequency-bar {
    transition: height 0.1s ease-out, background-color 0.2s ease;
}

/* NF value displays - smooth color and text transitions */
#currentNeuromarkerValue,
#normalizedValueDisplay,
#brightnessValue,
#fullscreenBrightnessText {
    transition: color 0.2s ease;
}

/* Monitor iframe - prevent flicker during updates */
.monitor-iframe {
    backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-font-smoothing: antialiased;
}

/* Canvas elements - hardware acceleration for smooth rendering */
canvas {
    backface-visibility: hidden;
    transform: translateZ(0);
    will-change: contents;
}

/* Prevent layout shifts during updates */
.nf-display-container {
    contain: layout style;
}

/* =============================================================================
 * WEBRTC VIDEO CALL STYLES
 * Styles for peer-to-peer video conferencing between provider and client
 * =============================================================================
 */

/* Video Call Container - floating bottom-right */
#videoCallContainer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: none;
}

#videoCallContainer.active {
    display: block;
}

/* Video call wrapper with dark theme */
.video-call-wrapper {
    width: 330px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

/* Drag handle at top of video call */
.video-call-drag-handle {
    cursor: grab;
    text-align: center;
    padding: 2px 0;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.4);
    font-size: 18px;
    line-height: 1;
    user-select: none;
    -webkit-user-select: none;
}
.video-call-drag-handle:active {
    cursor: grabbing;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
}

/* Remote video (large) */
#remoteVideo {
    width: 100%;
    display: block;
    background: #0d0d1a;
    min-height: 248px;
    object-fit: contain;
}

/* Local video preview (picture-in-picture during connected state) */
#localVideo {
    position: absolute;
    bottom: 60px;
    right: 8px;
    width: 90px;
    height: 68px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
    background: #1a1a2e;
    z-index: 1;
}

/* During calling state: local video fills the main area (no remote video yet) */
#videoCallContainer.calling #localVideo {
    position: static;
    width: 100%;
    height: auto;
    min-height: 248px;
    border: none;
    border-radius: 0;
    object-fit: contain;
}

/* During calling state: hide remote video placeholder */
#videoCallContainer.calling #remoteVideo {
    display: none;
}

/* Video call controls bar */
.video-call-controls {
    padding: 10px;
    display: flex;
    justify-content: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
}

/* Control buttons */
.video-call-controls button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

.video-call-controls button:hover {
    transform: scale(1.1);
}

/* Mute button */
.video-call-controls .btn-mute {
    background: #3a3a5a;
    color: white;
}

.video-call-controls .btn-mute.muted {
    background: #ffc107;
    color: #000;
}

/* Camera button */
.video-call-controls .btn-camera {
    background: #3a3a5a;
    color: white;
}

.video-call-controls .btn-camera.camera-off {
    background: #ffc107;
    color: #000;
}

/* End call button */
.video-call-controls .btn-end-call {
    background: #dc3545;
    color: white;
}

.video-call-controls .btn-end-call:hover {
    background: #c82333;
}

/* Call volume slider in video call controls */
.call-volume-control {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #3a3a5a;
    border-radius: 20px;
    padding: 0 10px;
    height: 34px;
}

.call-volume-control i {
    color: #fff;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.call-volume-control input[type="range"] {
    width: 70px;
    height: 4px;
    cursor: pointer;
    accent-color: #0dcaf0;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    outline: none;
}

.call-volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #0dcaf0;
    cursor: pointer;
}

.call-volume-control input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #0dcaf0;
    border: none;
    cursor: pointer;
}

/* Incoming Call Modal */
#incomingCallModal {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10001;
    display: none;
}

#incomingCallModal.active {
    display: block;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Incoming call wrapper */
.incoming-call-wrapper {
    width: 240px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

/* Incoming call icon animation */
.incoming-call-icon {
    font-size: 2.5rem;
    color: #198754;
    animation: ringPulse 1.5s ease-in-out infinite;
}

@keyframes ringPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.incoming-call-wrapper p {
    color: white;
    margin: 12px 0 8px 0;
    font-weight: 500;
}

.incoming-call-wrapper .caller-name {
    color: #aaa;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* Incoming call buttons */
.incoming-call-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.incoming-call-buttons button {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.incoming-call-buttons .btn-accept {
    background: #198754;
    color: white;
}

.incoming-call-buttons .btn-accept:hover {
    background: #157347;
}

.incoming-call-buttons .btn-decline {
    background: #dc3545;
    color: white;
}

.incoming-call-buttons .btn-decline:hover {
    background: #c82333;
}

/* Calling/Outgoing Call Modal (same position as incoming) */
#callingModal {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10001;
    display: none;
}

#callingModal.active {
    display: block;
    animation: slideInRight 0.3s ease-out;
}

/* Video Call Button (in header/controls) */
.btn-video-call {
    background: linear-gradient(135deg, #5468d4 0%, #5f3d85 100%);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-video-call:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(84, 104, 212, 0.4);
}

.btn-video-call:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Calling status indicator */
.calling-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border-radius: 8px;
}

.calling-status .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Connection status badge on video */
.video-call-status {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.video-call-status.connected {
    background: #198754;
    color: white;
}

.video-call-status.connecting {
    background: #ffc107;
    color: #000;
}

.video-call-status.disconnected {
    background: #dc3545;
    color: white;
}

/* Video Call Message Overlay */
#videoCallMessage {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10002;
    display: none;
}

#videoCallMessage.active {
    display: block;
    animation: slideInRight 0.3s ease-out;
}

.video-call-message-content {
    background: rgba(26, 26, 46, 0.95);
    color: #ccc;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    border-left: 3px solid #6c757d;
    max-width: 260px;
}

#videoCallMessage.error .video-call-message-content {
    border-left-color: #dc3545;
    color: #f8d7da;
}
