/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
  overscroll-behavior-y: contain;
  touch-action: manipulation;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* CSS Variables for consistent theming */
:root {
    --primary-color: #2196f3;
    --primary-dark: #1976d2;
    --primary-light: #e3f2fd;
    --secondary-color: #ff9800;
    --secondary-dark: #f57c00;
    --success-color: #4caf50;
    --success-dark: #45a049;
    --danger-color: #f44336;
    --danger-dark: #d32f2f;
    --warning-color: #ff9800;
    --warning-dark: #f57c00;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    --white: #ffffff;
    --black: #000000;
    --bg-color: #f5f5f5;
    --text-color: #333333;
    --border-color: #dee2e6;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    --box-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;

    /* Light theme specific */
    --card-bg: #ffffff;
    --header-bg: #ffffff;
    --surface-bg: #ffffff;
    --hover-bg: rgba(0, 0, 0, 0.05);
    --active-bg: rgba(33, 150, 243, 0.1);
    --skeleton-bg: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    --scrollbar-track: #f1f1f1;
    --scrollbar-thumb: #c1c1c1;
    --loading-overlay-bg: rgba(255, 255, 255, 0.9);
}

/* Dark theme variables */
[data-theme="dark"] {
    --primary-color: #4fc3f7;
    --primary-dark: #29b6f6;
    --primary-light: rgba(79, 195, 247, 0.1);
    --secondary-color: #ffb74d;
    --secondary-dark: #ffa726;
    --success-color: #66bb6a;
    --success-dark: #4caf50;
    --danger-color: #ef5350;
    --danger-dark: #f44336;
    --warning-color: #ffb74d;
    --warning-dark: #ffa726;
    --gray-100: #2d2d2d;
    --gray-200: #3d3d3d;
    --gray-300: #4d4d4d;
    --gray-400: #5d5d5d;
    --gray-500: #6d6d6d;
    --gray-600: #9e9e9e;
    --gray-700: #bdbdbd;
    --gray-800: #e0e0e0;
    --gray-900: #f5f5f5;
    --white: #1a1a1a;
    --black: #ffffff;
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --border-color: #3d3d3d;
    --box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    --box-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);

    /* Dark theme specific */
    --card-bg: #1e1e1e;
    --header-bg: #1e1e1e;
    --surface-bg: #1e1e1e;
    --hover-bg: rgba(255, 255, 255, 0.08);
    --active-bg: rgba(79, 195, 247, 0.15);
    --skeleton-bg: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    --scrollbar-track: #2d2d2d;
    --scrollbar-thumb: #5d5d5d;
    --loading-overlay-bg: rgba(18, 18, 18, 0.9);
}

/* Auto theme detection */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --primary-color: #4fc3f7;
        --primary-dark: #29b6f6;
        --primary-light: rgba(79, 195, 247, 0.1);
        --secondary-color: #ffb74d;
        --secondary-dark: #ffa726;
        --success-color: #66bb6a;
        --success-dark: #4caf50;
        --danger-color: #ef5350;
        --danger-dark: #f44336;
        --warning-color: #ffb74d;
        --warning-dark: #ffa726;
        --gray-100: #2d2d2d;
        --gray-200: #3d3d3d;
        --gray-300: #4d4d4d;
        --gray-400: #5d5d5d;
        --gray-500: #6d6d6d;
        --gray-600: #9e9e9e;
        --gray-700: #bdbdbd;
        --gray-800: #e0e0e0;
        --gray-900: #f5f5f5;
        --white: #1a1a1a;
        --black: #ffffff;
        --bg-color: #121212;
        --text-color: #e0e0e0;
        --border-color: #3d3d3d;
        --box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
        --box-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);

        /* Dark theme specific */
        --card-bg: #1e1e1e;
        --header-bg: #1e1e1e;
        --surface-bg: #1e1e1e;
        --hover-bg: rgba(255, 255, 255, 0.08);
        --active-bg: rgba(79, 195, 247, 0.15);
        --skeleton-bg: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
        --scrollbar-track: #2d2d2d;
        --scrollbar-thumb: #5d5d5d;
        --loading-overlay-bg: rgba(18, 18, 18, 0.9);
    }
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e9ecef;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

.loading-screen p {
    color: #6c757d;
    font-size: 16px;
    font-weight: 500;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Loading states for components */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--loading-overlay-bg);
    border-radius: var(--border-radius);
    z-index: 10;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid var(--gray-200);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 11;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    outline: none;
    position: relative;
    white-space: nowrap;
    min-height: 40px;
    text-transform: uppercase;
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
    border: 1px solid var(--gray-400);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-200);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
}

.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-dark);
}

.btn-warning {
    background: var(--warning-color);
    color: var(--white);
}

.btn-warning:hover:not(:disabled) {
    background: var(--warning-dark);
}

.btn-icon {
    padding: 8px;
    border-radius: 50%;
    background: transparent;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover:not(:disabled) {
    background: var(--hover-bg);
}

/* Cancel buttons styling (similar to modal-close) */
#cancelWorkoutBtn,
#cancelCircuitCreationBtn {
    color: var(--gray-700);
    transition: var(--transition);
}

#cancelWorkoutBtn:hover,
#cancelCircuitCreationBtn:hover {
    background: var(--hover-bg);
    color: var(--gray-700);
}

.btn-text {
    background: transparent;
    padding: 8px 16px;
    justify-content: flex-start;
}

.btn-text:hover:not(:disabled) {
    background: var(--hover-bg);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
    min-height: 32px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
    min-height: 48px;
}

/* Button loading state */
.btn.loading {
    color: transparent;
}

.btn.loading::before {
    background: none;
}

.btn.loading::after {
    border-color: currentColor;
    border-top-color: transparent;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 35%;
    padding: 12px 16px;
    border: 2px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
    background: var(--white);
    color: var(--gray-700);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-group input:invalid,
.form-group select:invalid,
.form-group textarea:invalid {
    border-color: var(--danger-color);
}

.form-group input:invalid:focus,
.form-group select:invalid:focus,
.form-group textarea:invalid:focus {
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.1);
}

.form-group input:valid,
.form-group select:valid,
.form-group textarea:valid {
    border-color: var(--success-color);
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
    opacity: 0.6;
}

.form-error {
    color: var(--danger-color);
    font-size: 12px;
    margin-top: 4px;
}

.form-help {
    color: var(--gray-500);
    font-size: 12px;
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.form-actions.center {
    justify-content: center;
}

.form-actions.left {
    justify-content: flex-start;
}

.form-actions.space-between {
    justify-content: space-between;
}

/* Input groups */
.input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group input {
    flex: 1;
}

.input-group .btn {
    white-space: nowrap;
}

/* Theme selector */
.theme-select {
    min-width: 140px;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-bg);
    color: var(--text-color);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.theme-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--active-bg);
}

.theme-select option {
    background: var(--surface-bg);
    color: var(--text-color);
}

/* Settings items layout */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
}

.setting-info {
    flex: 1;
}

.setting-info label {
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 4px;
    display: block;
}

.setting-info small {
    color: var(--gray-600);
    font-size: 13px;
    line-height: 1.4;
}

/* Checkbox and Radio styles */
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: auto;
    margin: 0;
}

.form-check label {
    margin: 0;
    cursor: pointer;
    user-select: none;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--header-bg);
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.app-title-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.app-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.header-actions {
    position: relative;
}

.header-actions .btn-icon {
    color: var(--text-color);
    transition: var(--transition);
}

.header-actions .btn-icon:hover {
    color: var(--primary-color);
    background: var(--hover-bg);
}

.user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    min-width: 200px;
    padding: 8px 0;
    display: none;
    transition: var(--transition);
}

.user-menu.active {
    display: block;
}

.user-info {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.user-info span {
    font-weight: 500;
    color: var(--text-color);
}

.user-menu .btn {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    border: none;
    border-radius: 0;
    padding: 12px 16px;
    transition: background-color 0.2s ease;
    color: var(--text-color);
}

.user-menu .btn:hover {
    background: var(--hover-bg);
}

.user-menu .btn i {
    margin-right: 12px;
    font-size: 18px;
    color: var(--text-color);
}

/* Tab Navigation */
.tab-navigation {
    background: var(--surface-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    position: sticky;
    top: 64px;
    z-index: 99;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    transition: background-color 0.3s ease;
}

.tab-navigation::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--gray-500);
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    position: relative;
    min-width: 80px;
    white-space: nowrap;
    text-decoration: none; /* For anchor tags */
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}

.tab-btn:hover:not(.active) {
    color: var(--primary-color);
    background: var(--primary-light);
}

.tab-btn.active, .tab-btn.active span {
    font-weight: 600;
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-btn.active::before {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px 2px 0 0;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

.tab-btn i {
    font-size: 30px;
    transition: var(--transition);
}

.tab-btn.active i {
    transform: scale(1.1);
}

.tab-btn span {
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition);
}

/* Tab content animations */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tab indicator for mobile */
.tab-indicator {
    position: absolute;
    bottom: 0;
    height: 3px;
    background: var(--primary-color);
    transition: var(--transition);
    border-radius: 2px 2px 0 0;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
    width: 100%;
}

.content-header {
    margin-bottom: 32px;
    text-align: center;
}

.content-header h2 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}

.content-header p {
    color: var(--gray-600);
    font-size: 16px;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface-bg);
    border-radius: var(--border-radius-lg);
    max-width: 500px;
    width: 90%;
    overflow-y: auto;
    box-shadow: var(--box-shadow-lg);
    transform: scale(0.9);
    animation: modalSlideIn 0.3s ease forwards;
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--surface-bg);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    z-index: 1;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-700);
    padding: 4px;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    background: var(--hover-bg);
    color: var(--gray-700);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background: var(--surface-bg);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

/* Modal sizes */
.modal-sm .modal-content {
    max-width: 300px;
}

.modal-lg .modal-content {
    max-width: 800px;
}

.modal-xl .modal-content {
    max-width: 1200px;
}

/* Modal full screen */
.modal-fullscreen .modal-content {
    width: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
}

/* Modal loading state */
.modal-content.loading {
    pointer-events: none;
}

.modal-content.loading::before {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--loading-overlay-bg);
    border-radius: var(--border-radius-lg);
    z-index: 100;
}

/* Workout Screen */
.workout-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface-bg);
    display: none;
    flex-direction: column;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.workout-screen.active {
    display: flex;
}

.workout-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-bg);
    transition: background-color 0.3s ease;
}

.workout-info h2 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.workout-info p {
    color: #666;
    font-size: 14px;
}

.workout-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    text-align: center;
}

.current-set {
    margin-bottom: 48px;
}

.set-target {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.set-target span:first-child {
    font-size: 48px;
    font-weight: 600;
    color: #2196f3;
}

.set-target span:nth-child(2) {
    font-size: 64px;
    font-weight: 700;
    color: #333;
}

.set-target span:last-child {
    font-size: 20px;
    color: #666;
}

.workout-actions {
    display: flex;
    gap: 16px;
}

.workout-actions .btn {
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
}

/* Responsive Design */
/* Mobile First - Base styles are for mobile */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }

    /* .tab-navigation {
        top: 64px;
    } */
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }

    .main-content {
        padding: 32px 24px;
    }

    .content-header h2 {
        font-size: 32px;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }

    .main-content {
        max-width: 1200px;
    }
}

/* Mobile specific styles */
@media (max-width: 767px) {
    /* .app-header {
        height: 56px;
    } */

    /* .header-content {
        padding: 0 12px;
        height: 56px;
    } */

    /* .app-title {
        font-size: 18px;
    } */

    /* .tab-navigation {
        top: 56px;
        padding: 0 8px;
    } */

    .main-content {
        padding: 16px 12px;
    }

    .content-header h2 {
        font-size: 24px;
    }

    .content-header p {
        font-size: 14px;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}

/* Extra small devices (phones, 320px and up) */
@media (max-width: 479px) {
    /* .app-header {
        height: 48px;
    } */

    /* .header-content {
        padding: 0 8px;
        height: 48px;
    } */

    /* .app-title {
        font-size: 16px;
    } */

    /* .tab-navigation {
        top: 48px;
        padding: 0 4px;
    } */

    .main-content {
        padding: 12px 8px;
    }

    .content-header {
        margin-bottom: 20px;
    }

    .content-header h2 {
        font-size: 20px;
    }

    .modal-content {
        width: 100%;
        max-height: none;
        border-radius: 0;
        margin: 0;
    }

    .modal-header h3 {
        font-size: 18px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .btn-sm {
        padding: 6px 12px;
        font-size: 11px;
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .modal-content {
        max-height: 90vh;
    }

    .tab-navigation {
        position: static;
    }

    .main-content {
        padding-top: 8px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .loading-spinner {
        border-width: 2px;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .btn:hover {
        transform: none;
    }

    .tab-btn.active i {
        transform: none;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

.text-xs { font-size: 12px; }
.text-sm { font-size: 14px; }
.text-base { font-size: 16px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }
.text-3xl { font-size: 32px; }

.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-primary { color: var(--primary-color); }
.text-secondary { color: var(--secondary-color); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.text-muted { color: var(--gray-500); }

.bg-primary { background-color: var(--primary-color); }
.bg-secondary { background-color: var(--secondary-color); }
.bg-success { background-color: var(--success-color); }
.bg-danger { background-color: var(--danger-color); }
.bg-warning { background-color: var(--warning-color); }
.bg-light { background-color: var(--gray-100); }
.bg-dark { background-color: var(--gray-800); }
.bg-white { background-color: var(--white); }

.border { border: 1px solid var(--gray-300); }
.border-top { border-top: 1px solid var(--gray-300); }
.border-bottom { border-bottom: 1px solid var(--gray-300); }
.border-left { border-left: 1px solid var(--gray-300); }
.border-right { border-right: 1px solid var(--gray-300); }

.rounded { border-radius: var(--border-radius); }
.rounded-lg { border-radius: var(--border-radius-lg); }
.rounded-full { border-radius: 50%; }

.shadow { box-shadow: var(--box-shadow); }
.shadow-lg { box-shadow: var(--box-shadow-lg); }

.m-0 { margin: 0; }
.m-1 { margin: 4px; }
.m-2 { margin: 8px; }
.m-3 { margin: 16px; }
.m-4 { margin: 24px; }
.m-5 { margin: 32px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mt-5 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mb-5 { margin-bottom: 32px; }

.ml-0 { margin-left: 0; }
.ml-1 { margin-left: 4px; }
.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 16px; }
.ml-4 { margin-left: 24px; }
.ml-5 { margin-left: 32px; }

.mr-0 { margin-right: 0; }
.mr-1 { margin-right: 4px; }
.mr-2 { margin-right: 8px; }
.mr-3 { margin-right: 16px; }
.mr-4 { margin-right: 24px; }
.mr-5 { margin-right: 32px; }

.p-0 { padding: 0; }
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 16px; }
.p-4 { padding: 24px; }
.p-5 { padding: 32px; }

.pt-0 { padding-top: 0; }
.pt-1 { padding-top: 4px; }
.pt-2 { padding-top: 8px; }
.pt-3 { padding-top: 16px; }
.pt-4 { padding-top: 24px; }
.pt-5 { padding-top: 32px; }

.pb-0 { padding-bottom: 0; }
.pb-1 { padding-bottom: 4px; }
.pb-2 { padding-bottom: 8px; }
.pb-3 { padding-bottom: 16px; }
.pb-4 { padding-bottom: 24px; }
.pb-5 { padding-bottom: 32px; }

.pl-0 { padding-left: 0; }
.pl-1 { padding-left: 4px; }
.pl-2 { padding-left: 8px; }
.pl-3 { padding-left: 16px; }
.pl-4 { padding-left: 24px; }
.pl-5 { padding-left: 32px; }

.pr-0 { padding-right: 0; }
.pr-1 { padding-right: 4px; }
.pr-2 { padding-right: 8px; }
.pr-3 { padding-right: 16px; }
.pr-4 { padding-right: 24px; }
.pr-5 { padding-right: 32px; }

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }

.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }

.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.items-stretch { align-items: stretch; }

.flex-1 { flex: 1; }
.flex-auto { flex: auto; }
.flex-none { flex: none; }

.w-full { width: 100%; }
.w-auto { width: auto; }
.h-full { height: 100%; }
.h-auto { height: auto; }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-scroll { overflow: scroll; }

.position-relative { position: relative; }
.position-absolute { position: absolute; }
.position-fixed { position: fixed; }
.position-sticky { position: sticky; }

.opacity-0 { opacity: 0; }
.opacity-25 { opacity: 0.25; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }

.select-none { user-select: none; }
.select-text { user-select: text; }
.select-all { user-select: all; }

.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

/* Animation utilities */
.transition { transition: var(--transition); }
.transition-none { transition: none; }

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-bounce {
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(-25%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

/* Hover utilities */
.hover\:bg-primary:hover { background-color: var(--primary-color); }
.hover\:bg-secondary:hover { background-color: var(--secondary-color); }
.hover\:text-primary:hover { color: var(--primary-color); }
.hover\:text-secondary:hover { color: var(--secondary-color); }
.hover\:opacity-75:hover { opacity: 0.75; }
.hover\:shadow:hover { box-shadow: var(--box-shadow); }

/* Focus utilities */
.focus\:outline-none:focus { outline: none; }
.focus\:ring:focus { box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1); }

/* Grid utilities */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.gap-0 { gap: 0; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }
.gap-5 { gap: 32px; }

.col-span-1 { grid-column: span 1 / span 1; }
.col-span-2 { grid-column: span 2 / span 2; }
.col-span-3 { grid-column: span 3 / span 3; }
.col-span-4 { grid-column: span 4 / span 4; }
.col-span-5 { grid-column: span 5 / span 5; }
.col-span-6 { grid-column: span 6 / span 6; }

/* Responsive utilities */
@media (min-width: 768px) {
    .md\:d-block { display: block !important; }
    .md\:d-flex { display: flex !important; }
    .md\:d-grid { display: grid !important; }
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md\:text-lg { font-size: 18px; }
    .md\:text-xl { font-size: 20px; }
}

@media (min-width: 992px) {
    .lg\:d-block { display: block !important; }
    .lg\:d-flex { display: flex !important; }
    .lg\:d-grid { display: grid !important; }
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .lg\:text-xl { font-size: 20px; }
    .lg\:text-2xl { font-size: 24px; }
}

/* Legacy utility classes for backward compatibility */
.hidden { display: none !important; }
.visible { display: block !important; }

/* Enhanced Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.focus-visible:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
    border-radius: var(--border-radius);
}

.skip-link:focus {
    top: 6px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --secondary-color: #000000;
        --text-color: #000000;
        --bg-color: #ffffff;
        --border-color: #000000;
        --gray-100: #f0f0f0;
        --gray-200: #e0e0e0;
        --gray-300: #d0d0d0;
        --gray-400: #b0b0b0;
        --gray-500: #808080;
        --gray-600: #606060;
        --gray-700: #404040;
        --gray-800: #202020;
        --gray-900: #000000;
    }

    .btn {
        border: 2px solid var(--border-color);
    }

    .card {
        border: 2px solid var(--border-color);
    }

    .input-group input {
        border: 2px solid var(--border-color);
    }
}

/* Print styles */
@media print {
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
    }

    .header,
    .nav-tabs,
    .btn,
    .modal,
    .modal-backdrop {
        display: none !important;
    }

    .tab-content {
        display: block !important;
    }

    .tab-pane {
        display: block !important;
    }

    .card {
        border: 1px solid #ddd !important;
        break-inside: avoid;
        margin-bottom: 1rem !important;
    }

    h1, h2, h3, h4, h5, h6 {
        break-after: avoid;
        color: black !important;
    }

    p, li {
        orphans: 3;
        widows: 3;
    }

    .page-break {
        page-break-before: always;
    }

    .no-print {
        display: none !important;
    }
}

/* Performance optimizations */
* {
    box-sizing: border-box;
}

*::before,
*::after {
    box-sizing: border-box;
}

/* Optimize repaints */
.card,
.btn,
.modal,
.tab-content {
    transform: translateZ(0);
    will-change: transform;
}

/* Loading skeleton styles */
.skeleton {
    background: var(--skeleton-bg);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: var(--border-radius);
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
    margin-bottom: 0;
}

.skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

.skeleton-button {
    height: 2.5rem;
    width: 6rem;
}

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

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: var(--border-radius);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--border-radius);
    transition: background-color 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Selection styles */
::selection {
    background: var(--primary-color);
    color: white;
}

::-moz-selection {
    background: var(--primary-color);
    color: white;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .input-group input {
        min-height: 44px;
    }

    .tab-nav button {
        min-height: 44px;
    }
}

/* Error boundary styles */
.error-boundary {
    padding: 2rem;
    text-align: center;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: var(--border-radius);
    color: #c33;
}

.error-boundary h2 {
    color: #c33;
    margin-bottom: 1rem;
}

.error-boundary p {
    margin-bottom: 1rem;
}

/* Notification System */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    z-index: 10000;
    display: none;
    max-width: 400px;
    font-weight: 500;
    animation: slideInRight 0.3s ease-out;
}

.notification.error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.notification.success {
    background: #f0f8ff;
    color: #0066cc;
    border: 1px solid #cce6ff;
}

.notification.warning {
    background: #fff8e1;
    color: #f57c00;
    border: 1px solid #ffcc02;
}

.notification.info {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
}

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

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--loading-overlay-bg);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay .loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
