/* style.css */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Add this to prevent text selection globally, then override for inputs */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none;    /* Firefox */
    -ms-user-select: none;     /* IE 10+ */
    user-select: none;         /* Standard */
}

/* Allow text selection for input fields */
input, textarea {
    -webkit-user-select: auto;
    -moz-user-select: auto;
    -ms-user-select: auto;
    user-select: auto;
}

:root {
    --primary-color: #6C63FF;
    --secondary-color: #D9FF87;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9ff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(108, 99, 255, 0.1);
    --card-bg: rgba(255, 255, 255, 0.7);
    --sidebar-width: 280px;
    --sidebar-collapsed: 80px;

    /* New colors for popup styling */
    --popup-bg-start: #f0f0f0; /* Light mode start gradient */
    --popup-bg-end: #e0e0e0;   /* Light mode end gradient */
    --popup-border: #cccccc;
    --popup-shadow-color: rgba(0,0,0,0.2);
    --popup-accent-glow: rgba(108, 99, 255, 0.2); /* Primary color glow */
}

/* Removed [data-theme="dark"] block and all dark mode specific styles */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    transition: all 0.3s ease;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 100;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-toggle {
    position: absolute;
    top: 1rem;
    right: -15px;
    width: 30px;
    height: 30px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
    transition: all 0.3s ease;
    z-index: 101;
}

.sidebar-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(108, 99, 255, 0.4);
}

.logo {
    padding: 0 2rem 2rem;
    text-align: center;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

.sidebar.collapsed .logo {
    padding: 0 1rem 2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: all 0.3s ease;
}

.sidebar.collapsed .logo h1 {
    font-size: 1rem;
}

.logo p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    transition: all 0.3s ease;
}

.sidebar.collapsed .logo p {
    opacity: 0;
    height: 0;
    margin: 0;
}

.nav-menu {
    list-style: none;
    padding: 0 1rem;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 12px;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.sidebar.collapsed .nav-link {
    padding: 1rem;
    justify-content: center;
}

.nav-link:hover {
    background: rgba(108, 99, 255, 0.1);
    color: var(--primary-color);
    transform: translateX(4px);
}

.sidebar.collapsed .nav-link:hover {
    transform: none;
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.15), rgba(217, 255, 135, 0.1));
    color: var(--primary-color);
    border: 1px solid rgba(108, 99, 255, 0.2);
    box-shadow: 0 4px 16px rgba(108, 99, 255, 0.2);
}

.nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.sidebar.collapsed .nav-icon {
    margin-right: 0;
}

.nav-text {
    transition: all 0.3s ease;
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* Removed Theme Toggle styles as it's removed from HTML */
.theme-toggle {
    display: none; /* Hide the theme toggle button */
}


/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    transition: all 0.3s ease;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.breadcrumb-item {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb-item:hover {
    color: var(--primary-color);
}

.breadcrumb-item.active {
    color: var(--primary-color);
    font-weight: 500;
}

.breadcrumb-separator {
    color: var(--text-secondary);
    opacity: 0.5;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
}

/* Circular Progress Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover::before {
    opacity: 1;
}

.circular-progress {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
}

.circular-progress svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.circular-progress .progress-ring {
    fill: none;
    stroke: rgba(108, 99, 255, 0.1);
    stroke-width: 6;
}

.circular-progress .progress-fill {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dasharray 0.6s ease;
}

.circular-progress .progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* New style for stat-card-action */
.stat-card-action {
    background: linear-gradient(135deg, var(--secondary-color), #c7ff5f);
    color: var(--text-primary);
    border: none;
    padding: 0.5rem 1rem; /* Smaller padding */
    border-radius: 8px; /* Slightly less rounded */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.8rem; /* Smaller font size */
    margin-top: 0.5rem; /* Space from label */
    display: inline-block; /* To allow margin auto for centering */
    position: relative;
    overflow: hidden;
}

.stat-card-action::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.stat-card-action:hover::before {
    left: 100%;
}

.stat-card-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(217, 255, 135, 0.4);
}

/* New style for stat-icon for non-progress icons */
.stat-icon {
    width: 80px; /* Match circular-progress width */
    height: 80px; /* Match circular-progress height */
    margin: 0 auto 1rem; /* Match circular-progress margin */
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon svg {
    width: 48px; /* Size of the icon itself */
    height: 48px;
    fill: var(--primary-color);
}


/* Performance Chart */
.performance-chart {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-period {
    display: flex;
    gap: 0.5rem;
}

.period-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.period-btn.active,
.period-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.chart-container {
    height: 200px;
    position: relative;
}

.chart-svg {
    width: 100%;
    height: 100%;
}

.chart-line {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-area {
    fill: url(#chartGradient);
    opacity: 0.3;
}

.chart-point {
    fill: var(--primary-color);
    stroke: white;
    stroke-width: 2;
    r: 4;
    transition: r 0.3s ease;
}

.chart-point:hover {
    r: 6;
}

/* Card Styles */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.card:hover::before {
    opacity: 1;
}

.card:hover .card-icon {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 8px 32px rgba(108, 99, 255, 0.3);
}

.card-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.card-description {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.card-action {
    background: linear-gradient(135deg, var(--secondary-color), #c7ff5f);
    color: var(--text-primary);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.card-action::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.card-action:hover::before {
    left: 100%;
}

.card-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(217, 255, 135, 0.4);
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
}

.tab-btn {
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn.active,
.tab-btn:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

.settings-section {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.settings-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.settings-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
    margin-right: 12px;
}

.setting-item {
    display: flex;
    flex-wrap: wrap; /* Allow content to wrap */
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    /* Added for better spacing and to prevent cutoff */
    gap: 0.5rem; /* Space between label and control */
}

.setting-item:hover {
    background: rgba(108, 99, 255, 0.05);
    margin: 0 -1rem;
    padding: 1rem;
    border-radius: 8px;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    color: var(--text-primary);
    font-weight: 500;
    flex-basis: 60%; /* Adjust width for label */
    /* Added for better responsiveness */
    min-width: 120px; /* Ensure label has minimum width */
    word-break: break-word; /* Allow long words to break */
}

/* Container for the two new controls */
.operation-controls {
    display: flex;
    gap: 0.5rem; /* Space between the two buttons */
    flex-basis: 35%; /* Control width for the container */
    justify-content: flex-end; /* Align controls to the right */
}

/* Styles for the individual toggle button (Enabled/Disabled) */
.toggle-control {
    background: rgba(108, 99, 255, 0.1); /* Default for disabled/neutral */
    color: var(--primary-color);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 8px;
    padding: 0.5rem 0.1rem; /* Reduced horizontal padding even further */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    flex-grow: 1; /* Allow it to grow within its container */
    white-space: nowrap; /* Prevent text wrapping */
}

/* Styles for enabled state of the toggle-control */
.toggle-control[data-state="enabled"] {
    background: var(--primary-color); /* A more prominent color for enabled */
    color: white; /* White text for enabled state */
    border-color: var(--primary-color);
}

/* Styles for disabled state of the toggle-control (can reuse default or make it more distinct) */
.toggle-control[data-state="disabled"] {
    background: rgba(108, 99, 255, 0.1);
    color: var(--primary-color);
    border-color: rgba(108, 99, 255, 0.2);
}

.toggle-control:hover {
    background: rgba(108, 99, 255, 0.2); /* Keep hover effect consistent */
    transform: scale(1.05);
}

.toggle-control[data-state="enabled"]:hover {
    background: var(--primary-color); /* Keep primary color on hover */
    filter: brightness(1.1); /* Slightly brighter on hover */
}

/* Styles for the dropdown trigger button (Settings button) */
.dropdown-trigger {
    background: rgba(108, 99, 255, 0.1);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: var(--primary-color);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1; /* Allow it to grow within its container */
    white-space: nowrap; /* Prevent text wrapping */
}

.dropdown-trigger:hover {
    background: rgba(108, 99, 255, 0.2);
    transform: scale(1.05);
}

.dropdown-trigger::after {
    content: "▼";
    margin-left: 0.5rem;
    display: inline-block;
    transition: transform 0.3s ease;
}

.operation-item.active .dropdown-trigger::after {
    transform: rotate(180deg);
}

/* Operation Dropdown Styles */
.operation-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    padding: 0 1rem;
    box-sizing: border-box;
}

.operation-item.active .operation-dropdown {
    max-height: 400px; /* adjust based on content */
    padding: 1rem; /* Add padding when active */
}

.dropdown-section {
    width: 100%;
}

.dropdown-section label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-inputs input[type="number"] {
    width: 60px;
    padding: 0.5rem;
    border: 1px solid var(--glass-border);
    background: var(--bg-secondary);
    border-radius: 8px;
    color: var(--text-primary);
    text-align: center;
}

.operation-dropdown select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--glass-border);
    background: var(--bg-secondary);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
}

.operation-dropdown input[type="checkbox"] {
    margin-right: 0.5rem;
}

/* New Practice Mode Styles */
.practice-mode-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.practice-mode-option input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    outline: none;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.practice-mode-option input[type="radio"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.practice-mode-option input[type="radio"]:checked::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background-color: var(--bg-primary);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.practice-mode-option input[type="number"] {
    flex-grow: 1;
    padding: 0.5rem;
    border: 1px solid var(--glass-border);
    background: var(--bg-secondary);
    border-radius: 8px;
    color: var(--text-primary);
    text-align: center;
}

/* Styling for the .setting-control class */
.setting-item .setting-control {
    /* Adjusted for better responsiveness and to prevent cutoff */
    flex-grow: 1; /* Allow it to take available space */
    min-width: 100px; /* Ensure it doesn't become too small */
    text-align: right; /* Align text to the right for values/links */
    padding: 0.5rem 0.75rem; /* Added horizontal padding */
    border: 1px solid var(--glass-border);
    background: var(--bg-secondary);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none; /* Ensure links don't have underlines by default */
    white-space: nowrap; /* Prevent text wrapping for links/buttons */
    overflow: hidden; /* Hide overflowing text */
    text-overflow: ellipsis; /* Add ellipsis for overflowing text */
    user-select: auto; /* Allow text selection */
}

.setting-item .setting-control[type="number"] {
    text-align: center; /* Center align for number inputs */
}

/* Specific adjustments for links/buttons within setting-item */
.setting-item a.setting-control,
.setting-item button.setting-control {
    display: inline-flex; /* Use inline-flex for alignment and content fitting */
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem; /* Adjust padding for button-like appearance */
    background: var(--primary-color); /* Example background for buttons/links */
    color: white; /* Example text color for buttons/links */
    border-color: var(--primary-color); /* Match border color */
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.2); /* Subtle shadow */
    transition: all 0.3s ease;
}

.setting-item a.setting-control:hover,
.setting-item button.setting-control:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
}

/* Styles for <pre> and <code> tags within the settings-section */
.settings-section pre {
    background-color: var(--bg-secondary); /* Using theme variable for background */
    color: var(--text-primary); /* Using theme variable for text color */
    padding: 0.4em 0.8em; /* Adjusted padding to be more snug vertically */
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    /* Changed display and width to make it fit content more snugly */
    display: inline-block; /* Changed from flex-grow to inline-block */
    width: fit-content; /* Make width fit content */
    min-width: unset; /* Remove min-width constraint */
    text-align: right; /* Align to the right to match other controls */
    border: 1px solid var(--glass-border); /* Add a subtle border */
    /* Ensure user-select is explicitly set for pre and code */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.settings-section pre code {
    font-size: 1em; /* Keep font size as specified */
    /* Ensure user-select is explicitly set for pre and code */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Adjustments for responsiveness on smaller screens for pre/code */
@media (max-width: 768px) {
    .settings-section pre {
        width: 100%; /* Take full width on small screens */
        text-align: left; /* Align text to left for better readability */
        white-space: pre-wrap; /* Allow wrapping within the pre tag */
        word-break: break-all; /* Break long words */
    }
}


/* Save Settings Button Style */
.save-settings-btn {
    display: block;
    width: fit-content;
    margin: 2rem auto 0; /* Center the button and add top margin */
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(108, 99, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.save-settings-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(108, 99, 255, 0.4);
}

/* Save Confirmation Message */
.save-confirmation {
    background-color: #4CAF50; /* Green background for success */
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.save-confirmation.show {
    opacity: 1;
    visibility: visible;
}
.save-confirmation svg {
    width: 24px;
    height: 24px;
    fill: white;
}


/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(108, 99, 255, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 12px 48px rgba(108, 99, 255, 0.6);
}

/* Tooltip */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    opacity: 1;
    animation: tooltipFadeIn 0.3s ease;
}

.tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border: 5px solid transparent;
    border-top-color: var(--text-primary);
    z-index: 1000;
    animation: tooltipFadeIn 0.3s ease;
}

@keyframes tooltipFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, rgba(108, 99, 255, 0.1) 25%, rgba(108, 99, 255, 0.2) 50%, rgba(108, 99, 255, 255, 0.1) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    height: 200px;
    margin-bottom: 1rem;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-text.long { width: 100%; }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    /* Updated styling for the modal to mimic index.html container */
    background: linear-gradient(145deg, var(--popup-bg-start), var(--popup-bg-end));
    border-radius: 20px;
    padding: 1.5rem; /* Slightly reduced padding */
    max-width: 600px; /* Kept existing max-width */
    width: 90%; /* Kept existing width */
    max-height: 90vh; /* Increased from 80vh to 90vh */
    overflow-y: auto;
    transform: scale(0.8) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--popup-border); /* New border style */
    box-shadow: 0 20px 40px var(--popup-shadow-color), 0 0 20px var(--popup-accent-glow); /* Enhanced shadow */
    text-align: center; /* Center content within the modal */
    display: flex; /* Make modal content a flex container */
    flex-direction: column; /* Stack content vertically */
    align-items: center; /* Center items horizontally */
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    width: 100%; /* Ensure header spans full width */
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(108, 99, 255, 0.1);
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        padding: 1rem 0;
        height: auto;
    }
    
    .sidebar.collapsed {
        width: 100%;
    }
    
    .nav-menu {
        display: flex;
        overflow-x: auto;
        padding: 0 1rem;
    }
    
    .nav-item {
        margin-right: 0.5rem;
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .nav-link {
        padding: 1rem;
        justify-content: center;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .page-title {
        font-size: 2rem;
    }

    .fab {
        bottom: 1rem;
        right: 1rem;
    }

    .sidebar-toggle {
        display: none;
    }

    /* Adjusted for better responsiveness on smaller screens */
    .settings-section {
        padding: 1.5rem; /* Reduce padding on smaller screens */
    }

    .setting-item {
        flex-direction: column; /* Stack label and control vertically */
        align-items: flex-start; /* Align items to the start */
        padding: 0.75rem 0; /* Adjust padding */
    }

    .setting-label {
        flex-basis: auto; /* Remove fixed basis on small screens */
        width: 100%; /* Take full width */
        margin-bottom: 0.5rem; /* Add space below label */
    }

    .setting-item .setting-control {
        width: 100%; /* Make controls take full width */
        text-align: left; /* Align text to left for better readability */
        white-space: normal; /* Allow text to wrap */
        text-overflow: clip; /* No ellipsis when wrapping */
    }

    .operation-controls {
        width: 100%; /* Take full width */
        justify-content: flex-start; /* Align controls to the left */
    }

    /* Removed theme-toggle responsive styles as it's hidden */
}

/* Toggle Switch Styles (No longer used for "Failure Conditions" but kept for reference if needed elsewhere) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    margin-left: 10px; /* Adjust spacing */
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px; /* Rounded slider */
}

.toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%; /* Rounded handle */
}

.toggle-switch input:checked + .slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .slider:before {
    transform: translateX(20px);
}

/* Pie Chart Styles (for Chart.js) */
.pie-chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
}

#operationPieChart {
    max-width: 400px;
    margin: auto;
}

#slidersContainer {
    max-width: 400px;
    margin: auto;
    width: 100%; /* Ensure sliders take full width of container */
}

#slidersContainer input[type="range"] {
    width: 100%;
    -webkit-appearance: none; /* Remove default styling for Chrome/Safari */
    appearance: none;
    height: 8px;
    background: var(--bg-secondary);
    outline: none;
    border-radius: 5px;
    transition: background 0.2s ease;
}

#slidersContainer input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#slidersContainer input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Training Modal Specific Styles */
#trainingModal .modal {
    /* Adjusted max-height for better fit */
    max-height: 90vh; /* Increased from 80vh to 90vh */
    padding: 1.5rem; /* Slightly reduced padding */
}

#trainingModal .modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Adjusted gap for more compact layout */
    gap: 1rem; /* Reduced from 1.5rem */
    width: 100%; /* Ensure body takes full width of modal */
}

#trainingProgress {
    width: 100%;
    height: 10px;
    background-color: var(--popup-border); /* Use popup border color for background */
    border-radius: 50px;
    overflow: hidden;
    margin-bottom: 0.5rem; /* Reduced margin */
}

#trainingProgressBar {
    height: 100%;
    width: 0%;
    /* Use a gradient similar to index.html progress bar */
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease-out;
}

#timerDisplay {
    font-size: 1.1em; /* Slightly smaller font */
    font-weight: bold; /* Bold like index.html stats */
    color: var(--text-secondary); /* Keep existing text color */
    margin: 0.25rem 0; /* Reduced margin */
}

/* Stopwatch Timer Styles */
#stopwatchDisplay {
    font-size: 1.2em; /* Slightly larger than timerDisplay */
    font-weight: bold;
    color: var(--primary-color); /* Use primary color for stopwatch */
    margin-top: 0.5rem; /* Space from problem display */
    margin-bottom: 1rem; /* Space before input */
    text-shadow: 0 0 10px rgba(108, 99, 255, 0.3); /* Subtle glow */
    transition: all 0.3s ease;
}

#problemCountDisplay {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem; /* Space between problem count and scores */
    font-size: 1.1em; /* Slightly smaller font */
    font-weight: bold;
    color: var(--text-secondary);
    margin: 0.25rem 0;
}

.score-number {
    font-size: 1.2em; /* Slightly larger for scores */
    font-weight: bold;
    transition: transform 0.2s ease-out; /* For animation */
}

.score-number.correct {
    color: #06D6A0; /* Green */
    text-shadow: 0 0 8px #06D6A0, 0 0 15px #06D6A0; /* Green glow */
}

.score-number.incorrect {
    color: #FF6B6B; /* Red */
    text-shadow: 0 0 8px #FF6B6B, 0 0 15px #FF6B6B; /* Red glow */
}

#problemDisplay {
    font-size: 2.5em; /* Slightly smaller font size */
    font-weight: bold; /* Bold like index.html problem */
    color: var(--primary-color); /* Use primary color for problem */
    margin: 1rem 0; /* Reduced margin */
    text-shadow: 0 0 20px var(--popup-accent-glow); /* Add text shadow */
}

/* New container for input and repeat button */
.answer-input-container {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between input and button */
    margin: 0.75rem auto; /* Reduced margin, center horizontally */
    width: fit-content; /* Adjust width to content */
}

#answerInput {
    width: 200px; /* Fixed width like index.html */
    padding: 12px 18px; /* Slightly smaller padding */
    font-size: 1.8em; /* Slightly smaller font size */
    text-align: center;
    border: 2px solid var(--popup-border); /* Match popup border */
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

#answerInput:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-secondary);
    box-shadow: 0 0 20px var(--popup-accent-glow);
}

#answerInput:disabled {
    background-color: #e0e0e0; /* Lighter background when disabled */
    cursor: not-allowed;
    opacity: 0.7;
}


/* Style for the repeat button */
.repeat-problem-btn {
    background: var(--primary-color);
    border: none;
    border-radius: 12px;
    width: 50px; /* Fixed width for the button */
    height: 50px; /* Fixed height for the button */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
    flex-shrink: 0; /* Prevent button from shrinking */
}

.repeat-problem-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(108, 99, 255, 0.4);
}

/* Styles for the speaker icon within the button */
.repeat-problem-btn .speaker {
    width: 0;
    height: 0;
    background: none;
    border-top: 0.75em solid transparent;
    border-bottom: 0.75em solid transparent;
    border-right: 0.9em solid white; /* Icon color, changed to white for contrast */
    position: relative;
    transform: scale(0.7); /* Adjust size of the icon within the button */
}

.repeat-problem-btn .speaker:before {
    content: "";
    position: absolute;
    top: -0.25em;
    left: 0;
    width: 1.1em;
    height: 0.5em;
    background: white; /* Icon color, changed to white for contrast */
    border-radius: 1px 0.3em 0.3em 1px;
}


#feedbackMessage {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.75rem;
    min-height: 1.5em;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#trainingControls {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    justify-content: center;
    width: 100%;
}

#trainingControls button {
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 8px;
    box-shadow: 0 5px 15px var(--popup-shadow-color), inset 0 1px 0 rgba(255,255,255,0.1);
    border: 1px solid var(--popup-border);
}

#endSessionBtn {
    background: var(--text-secondary);
    color: white;
}

#endSessionBtn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* New styles for confirmation message and buttons */
#endSessionConfirmation {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    margin-top: 1rem;
    width: 100%;
}

#endSessionConfirmation.active {
    display: flex;
}

#confirmationMessage {
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.5;
    max-width: 400px;
}

#confirmationButtons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    width: 100%;
}

#confirmEndBtn {
    background: #FF6B6B; /* Red for destructive action */
    color: white;
    border-color: #FF6B6B;
}

#confirmEndBtn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255,107,107,0.4);
}

#cancelEndBtn {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

#cancelEndBtn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--popup-accent-glow);
}

/* Summary Modal Specific Styles */
#summaryModal .modal-body {
    text-align: left;
    padding: 1rem 2rem;
    width: 100%;
}

#summaryModal .summary-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--glass-border);
}

#summaryModal .summary-item:last-child {
    border-bottom: none;
    margin-top: 1rem;
    font-size: 1.1rem;
    font-weight: bold;
}

#summaryModal .summary-label {
    color: var(--text-secondary);
}

#summaryModal .summary-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* New styles for Recent Performance Card */
.recent-sessions-card {
    grid-column: 1 / -1; /* Span all columns in the grid */
    padding: 2rem;
}

.recent-sessions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem; /* Space between micro cards */
    margin-top: 1.5rem;
    max-height: 400px; /* Limit height to enable scrolling */
    overflow-y: auto; /* Enable vertical scrolling */
    padding-right: 10px; /* Space for scrollbar */
}

.session-date-group {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    margin-bottom: 1rem;
    /* Removed overflow: hidden; */
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.session-date-group summary {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.1), rgba(217, 255, 135, 0.1));
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease;
}

.session-date-group summary:hover {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.2), rgba(217, 255, 135, 0.2));
}

.session-date-group summary::-webkit-details-marker {
    display: none; /* Hide default marker */
}

.session-date-group summary::after {
    content: '▼'; /* Custom arrow */
    transition: transform 0.2s ease;
}

.session-date-group[open] summary::after {
    transform: rotate(180deg);
}

.session-micro-card {
    background: var(--card-bg); /* Changed to use --card-bg variable */
    border-top: 1px dashed var(--glass-border); /* Dashed border for separation */
    padding: 1rem 1.5rem;
    transition: background 0.2s ease;
    position: relative; /* Needed for positioning the delete button */
}
.session-micro-card:first-of-type {
    border-top: none; /* No top border for the first session in a group */
}

.session-micro-card:hover {
    background: rgba(108, 99, 255, 0.05); /* Light hover effect */
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary); /* Changed to primary text color */
}

.session-date-time { /* Renamed from session-date for clarity */
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.session-mode-label { /* Renamed from session-mode for clarity */
    font-size: 0.9rem;
    color: var(--primary-color); /* Highlight mode */
}

.session-details p {
    font-size: 0.8rem; /* Slightly smaller font for details */
    color: #333; /* Darker color for readability on white background */
    margin-bottom: 0.1rem; /* Reduced margin */
    line-height: 1.4;
}

.session-details p:last-child {
    margin-bottom: 0;
}

.session-details strong {
    color: var(--text-primary);
}

.pagination-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.pagination-button {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination-button:hover:not(.active) {
    background: rgba(108, 99, 255, 0.1);
    color: var(--primary-color);
}

.pagination-button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    cursor: default;
}

/* Delete Button for Sessions */
.delete-session-btn {
    position: absolute;
    top: 1rem;
    right: 0.5rem; /* Adjusted right position */
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    color: var(--text-secondary); /* Default color */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1; /* Ensure it's above other content */
}

.delete-session-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor; /* Use current text color */
}

.delete-session-btn:hover {
    background-color: rgba(255, 107, 107, 0.1); /* Light red hover */
    color: #FF6B6B; /* Red on hover */
    transform: scale(1.1);
}

.delete-session-btn.delete-confirm {
    color: #FF6B6B; /* Red when clicked once */
    animation: pulseRed 0.7s infinite alternate;
}

@keyframes pulseRed {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(1.1); opacity: 0.8; }
}

/* New Countdown Display Styles */
#countdownDisplay {
    font-size: 5em; /* Large font for countdown */
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 0 0 20px var(--popup-accent-glow);
    margin: 2rem 0; /* Center it vertically */
    position: absolute; /* Position absolutely within the modal-body */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none; /* Hidden by default */
    animation: popIn 0.3s ease-out; /* Simple pop-in animation */
}

@keyframes popIn {
    from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
