/* Dark/Light Mode Variables */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --card-bg: #ffffff;
    --gauge-bg: #e9ecef;
    --gauge-fill: #007bff;
    --gauge-fill-danger: #dc3545;
    --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #f8f9fa;
    --border-color: #495057;
    --card-bg: #2d2d2d;
    --gauge-bg: #495057;
    --gauge-fill: #0d6efd;
    --gauge-fill-danger: #dc3545;
    --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3);
}

/* Base Styles */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.card {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    box-shadow: var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.theme-toggle button {
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.theme-toggle button:hover {
    transform: scale(1.1);
}

/* Ring Gauge Styles - Apple Fitness App Style */
.gauge-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin: 20px 0;
    flex-wrap: wrap;
    gap: 30px;
}

.ring-gauge {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ring-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.ring-background {
    fill: none;
    stroke: var(--gauge-bg);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke 0.3s ease;
}

.ring-progress {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 314.16; /* 2 * π * 50 */
    stroke-dashoffset: 314.16;
    transition: stroke-dashoffset 0.2s ease-out, stroke 0.1s ease-out;
    transform-origin: center;
    will-change: stroke-dashoffset;
}

/* Color states for ring progress */
.ring-progress.safe {
    stroke: #34c759; /* Apple Green */
    stroke-dasharray: 314.16;
}

.ring-progress.caution {
    stroke: #ff9500; /* Apple Orange */
    stroke-dasharray: 314.16;
}

.ring-progress.danger {
    stroke: #ff3b30; /* Apple Red */
    stroke-dasharray: 314.16;
    filter: drop-shadow(0 0 8px rgba(255, 59, 48, 0.4));
}

.ring-progress.pulse {
    animation: ring-pulse 1s ease-in-out infinite alternate;
}

@keyframes ring-pulse {
    0% { 
        stroke-width: 8;
        filter: drop-shadow(0 0 8px rgba(255, 59, 48, 0.4));
    }
    100% { 
        stroke-width: 12;
        filter: drop-shadow(0 0 16px rgba(255, 59, 48, 0.6));
    }
}

.ring-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 2;
}

.ring-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
}

.ring-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-variant-numeric: tabular-nums;
}

/* Ring Gauge Hover Effects */
.ring-gauge:hover .ring-svg {
    transform: rotate(-90deg) scale(1.05);
    transition: transform 0.2s ease;
}

.ring-gauge:hover .ring-progress {
    stroke-width: 10;
    transition: stroke-width 0.2s ease;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .ring-progress {
        transition: stroke-dashoffset 0.15s ease-out, stroke 0.1s ease-out;
    }
    
    .ring-gauge:hover .ring-svg {
        transform: rotate(-90deg) scale(1.02);
    }
}

/* Alert Styles */
.alert {
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    animation: slideInDown 0.5s ease;
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Statistics Cards */
.card .fa-2x {
    transition: transform 0.3s ease;
}

.card:hover .fa-2x {
    transform: scale(1.1);
}

/* Progress Bar */
.progress {
    height: 8px;
    border-radius: 4px;
    background-color: var(--gauge-bg);
}

.progress-bar {
    transition: width 0.5s ease;
}

/* List Group */
.list-group-item {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
    transition: background-color 0.3s ease;
}

.list-group-item:hover {
    background-color: var(--bg-secondary);
}

.list-group-item .text-muted {
    color: var(--text-secondary) !important;
}

/* Form Controls */
.form-range {
    background: var(--gauge-bg);
    position: relative;
}

.form-range::-webkit-slider-thumb {
    background: var(--gauge-fill);
    border: 2px solid var(--card-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.form-range::-moz-range-thumb {
    background: var(--gauge-fill);
    border: 2px solid var(--card-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.form-label {
    color: var(--text-primary);
    font-weight: 500;
}

/* Enhanced Tooltip Styling for Sliders */
.form-range[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: tooltip-fade-in 0.2s ease;
}

.form-range[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    pointer-events: none;
}

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Dark mode tooltip styling */
[data-theme="dark"] .form-range[title]:hover::after {
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a1a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .form-range[title]:hover::before {
    border-top-color: rgba(255, 255, 255, 0.95);
}

/* Dark mode text readability improvements */
[data-theme="dark"] .card-header h5 {
    color: #ffffff !important;
    font-weight: 600;
}

[data-theme="dark"] .card-header h5 i {
    color: #ffffff !important;
}

[data-theme="dark"] .card-header h5.mb-0 {
    color: #ffffff !important;
    font-weight: 600;
}

[data-theme="dark"] .card-header h5.mb-0 i {
    color: #ffffff !important;
}

/* More specific targeting for card headers */
[data-theme="dark"] .card .card-header h5 {
    color: #ffffff !important;
    font-weight: 600 !important;
}

[data-theme="dark"] .card .card-header h5 i {
    color: #ffffff !important;
}

/* Target all h5 elements in dark mode */
[data-theme="dark"] h5 {
    color: #ffffff !important;
    font-weight: 600 !important;
}

[data-theme="dark"] h5 i {
    color: #ffffff !important;
}

[data-theme="dark"] .card-body h3 {
    color: #ffffff !important;
    font-weight: 600;
}

[data-theme="dark"] .card-body h3 i {
    color: #ffffff !important;
}

[data-theme="dark"] .card-text {
    color: #f8f9fa !important;
}

[data-theme="dark"] .form-label {
    color: #ffffff !important;
    font-weight: 600;
}

[data-theme="dark"] .text-muted {
    color: #adb5bd !important;
}

[data-theme="dark"] .text-danger {
    color: #ff6b6b !important;
}

[data-theme="dark"] .display-4 {
    color: #ff6b6b !important;
}

[data-theme="dark"] .h2 {
    color: #ffffff !important;
}

[data-theme="dark"] .h4 {
    color: #ff6b6b !important;
    font-weight: 700;
}

[data-theme="dark"] .patient-details h5 {
    color: #ffffff !important;
    font-weight: 700;
}

[data-theme="dark"] .patient-details small {
    color: #e9ecef !important;
}

[data-theme="dark"] .battery-text {
    color: #ffffff !important;
    font-weight: 800;
}

[data-theme="dark"] .battery-info {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Patient Information section dark mode fixes */
[data-theme="dark"] .card-body strong {
    color: #ffffff !important;
    font-weight: 700 !important;
}

[data-theme="dark"] .card-body {
    color: #f8f9fa !important;
}

[data-theme="dark"] .card-body .row {
    color: #f8f9fa !important;
}

[data-theme="dark"] .card-body .row div {
    color: #f8f9fa !important;
}

/* Target all text in card body */
[data-theme="dark"] .card .card-body {
    color: #f8f9fa !important;
}

[data-theme="dark"] .card .card-body * {
    color: #f8f9fa !important;
}

[data-theme="dark"] .card .card-body strong {
    color: #ffffff !important;
    font-weight: 700 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gauge-container {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    .ring-gauge {
        width: 120px;
        height: 120px;
    }
    
    .ring-value {
        font-size: 16px;
    }
    
    .ring-label {
        font-size: 11px;
    }
    
    .d-flex {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .patient-details {
        text-align: center;
        margin-right: 0 !important;
        margin-bottom: 10px;
    }
    
    .patient-avatar {
        width: 50px;
        height: 50px;
    }
    
    .battery-info {
        justify-content: center;
        font-size: 14px;
        padding: 8px 14px;
        min-width: 100px;
        gap: 8px;
    }
    
    .battery-icon {
        font-size: 20px;
    }
    
    .battery-text {
        font-size: 16px;
    }
    
    .theme-toggle {
        bottom: 10px;
        right: 10px;
    }
    
    .theme-toggle button {
        width: 40px;
        height: 40px;
    }
}

/* Patient Info Styling - Removed container, now integrated into navbar */

/* Patient Avatar */
.patient-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.patient-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Battery Info Styling */
.battery-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 700;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    min-width: 120px;
    justify-content: center;
}

.battery-info:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.battery-icon {
    font-size: 24px;
    transition: all 0.2s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.battery-text {
    font-weight: 800;
    font-size: 18px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.8px;
}

/* Battery Level Colors */
.battery-icon.battery-critical {
    color: #ff3b30; /* Apple Red */
    animation: battery-blink 1s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 8px rgba(255, 59, 48, 0.6));
}

.battery-icon.battery-low {
    color: #ff9500; /* Apple Orange */
    filter: drop-shadow(0 0 4px rgba(255, 149, 0, 0.4));
}

.battery-icon.battery-medium {
    color: #ffcc00; /* Apple Yellow */
    filter: drop-shadow(0 0 4px rgba(255, 204, 0, 0.4));
}

.battery-icon.battery-good {
    color: #34c759; /* Apple Green */
    filter: drop-shadow(0 0 4px rgba(52, 199, 89, 0.4));
}

.battery-icon.battery-excellent {
    color: #007aff; /* Apple Blue */
    filter: drop-shadow(0 0 4px rgba(0, 122, 255, 0.4));
}

@keyframes battery-blink {
    0% { 
        opacity: 1;
        transform: scale(1);
    }
    100% { 
        opacity: 0.4;
        transform: scale(1.1);
    }
}

/* Patient Details */
.patient-details {
    text-align: right;
}

.patient-details h5 {
    margin-bottom: 4px;
    font-weight: 600;
}

.patient-details small {
    font-size: 11px;
    opacity: 0.9;
}

/* Badge Styling */
.badge {
    font-size: 0.75em;
    padding: 0.5em 0.75em;
}

/* Header Styling */
header {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid #404040;
}

/* Card Hover Effects */
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--gauge-fill);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gauge-fill-danger);
}
