@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    /* Modern Color Palette */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #10b981;
    --secondary-light: #34d399;
    --accent: #f59e0b;

    /* Backgrounds */
    --bg-body: linear-gradient(135deg, #f5f7fa 0%, #e8eef5 100%);
    --bg-card: #ffffff;
    --bg-sidebar: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);

    /* Text */
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --text-light: #9ca3af;

    /* Borders & Shadows */
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    --sidebar-width: 300px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-light: #a5b4fc;
    --primary-dark: #6366f1;
    --secondary: #34d399;
    --secondary-light: #6ee7b7;
    --accent: #fbbf24;

    --bg-body: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --bg-card: #1e293b;
    --bg-sidebar: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-light: #64748b;

    --border: #334155;
    --border-light: #1e293b;
    --shadow-glow: 0 0 20px rgba(129, 140, 248, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
    line-height: 1.6;
    min-height: 100vh;
}

body.rtl {
    direction: rtl;
    font-family: 'Cairo', 'Poppins', sans-serif;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
    border-radius: 10px;
    border: 2px solid var(--border-light);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    box-shadow: var(--shadow-lg);
}

.sidebar.collapsed {
    width: 80px;
}

/* Hide only logo text and progress widget */
.sidebar.collapsed .logo-area h1,
.sidebar.collapsed .progress-widget {
    display: none;
}

/* Hide the word "Unit" - show only the number */
.sidebar.collapsed .unit-item>div>span::before {
    content: '';
}

/* Hide unit titles completely when collapsed */
.sidebar.collapsed .unit-item>div>div {
    display: none;
}

/* Adjust unit item padding */
.sidebar.collapsed .unit-item {
    justify-content: center;
    padding: 0.6rem 0.4rem;
}

/* Adjust logo area */
.sidebar.collapsed .logo-area {
    padding: 1.5rem 0.5rem;
}

/* Dark mode button as circle only */
.sidebar.collapsed .sidebar-footer {
    padding: 1rem 0.5rem;
}

.sidebar.collapsed .theme-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
    min-width: auto;
}

/* Hide dark mode text, keep icon */
.sidebar.collapsed .theme-btn span:not(.icon) {
    display: none;
}

.sidebar.collapsed .theme-btn .icon {
    font-size: 1.5rem;
    margin: 0;
}

body.rtl .sidebar {
    border-right: none;
    border-left: 1px solid var(--border);
}

/* Logo Area */
.logo-area {
    padding: 1.5rem 1rem;
    text-align: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    margin: 0.5rem;
    box-shadow: var(--shadow-md);
    position: relative;
}

.sidebar-toggle {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-toggle:active {
    transform: scale(1.05);
}

.toggle-icon {
    font-size: 1rem;
    transition: all 0.3s ease;
    display: block;
    font-weight: bold;
}

/* When sidebar is open, show X icon */
.sidebar:not(.collapsed) .toggle-icon::before {
    content: '✕';
    font-size: 1.25rem;
}

/* When sidebar is collapsed, show hamburger icon */
.sidebar.collapsed .toggle-icon::before {
    content: '☰';
    font-size: 1rem;
}

/* Hide original icon text */
.toggle-icon {
    font-size: 0;
}

body.rtl .sidebar-toggle {
    left: auto;
    right: 0.75rem;
}

body.rtl .toggle-icon {
    transform: none;
}

body.rtl .sidebar.collapsed .toggle-icon {
    transform: none;
}

.logo-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    animation: float 3s ease-in-out infinite;
    transition: all 0.3s ease;
}

.sidebar.collapsed .logo-icon {
    font-size: 1.75rem;
    margin-bottom: 0;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

.logo-area h1 {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Progress Widget */
.progress-widget {
    padding: 1.5rem;
    margin: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

.progress-track {
    background: var(--border-light);
    height: 10px;
    border-radius: 99px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    background: linear-gradient(90deg, var(--secondary) 0%, var(--secondary-light) 100%);
    height: 100%;
    width: 0%;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 99px;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.progress-container {
    margin-top: 1rem;
}

.progress-bar-bg {
    background-color: var(--border);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-bar-fill {
    background-color: var(--secondary);
    height: 100%;
    width: 0%;
    transition: width 0.5s ease;
}

.units-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.unit-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    background: var(--bg-card);
    position: relative;
    overflow: hidden;
}

.unit-item>div {
    position: relative;
    z-index: 1;
    width: 100%;
}

/* First div - unit number (show when collapsed) */
.unit-item>div:first-child {
    display: none;
}

.sidebar.collapsed .unit-item>div:first-child {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Second div - unit title (show when open) */
.unit-item>div:last-child {
    display: block;
}

.sidebar.collapsed .unit-item>div:last-child {
    display: none;
}

/* Unit number styling */
.unit-number {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    font-weight: 600;
}

/* When collapsed, make number bigger */
.sidebar.collapsed .unit-number {
    font-size: 1.25rem;
    color: #4a5568;
    opacity: 1;
    font-weight: 700;
    text-transform: none;
    letter-spacing: normal;
}

/* Unit title styling */
.unit-title {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.unit-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), var(--primary-light));
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.unit-item:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(129, 140, 248, 0.05));
    border-color: var(--primary-light);
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.unit-item:hover::before {
    transform: scaleY(1);
}

.unit-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--primary);
    transform: translateX(8px);
}

.unit-item.active>div>span {
    opacity: 0.9;
}

.unit-item.active::before {
    background: rgba(255, 255, 255, 0.3);
    transform: scaleY(1);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-card);
    margin: 0.5rem;
    border-radius: var(--radius-lg);
}

.theme-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    font-size: 0.875rem;
}

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

.theme-btn .icon {
    font-size: 1.125rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Prevent overflow */
}

/* Unit Header */
.unit-header {
    background: var(--bg-card);
    padding: 2.5rem 3rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.unit-header::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light), var(--secondary));
}

.breadcrumb {
    display: inline-block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(129, 140, 248, 0.1));
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.unit-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    margin: 0;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-main);
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 100;
    background: var(--bg-card);
    /* bg for visibility */
    padding: 0.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

body.rtl .mobile-menu-btn {
    left: auto;
    right: 1rem;
}

/* Tabs */
.tabs-nav {
    display: flex;
    gap: 1rem;
    padding: 1.5rem 3rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

.tab-btn {
    background: transparent;
    border: 2px solid transparent;
    padding: 0.875rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    border-radius: var(--radius-md);
    position: relative;
}

.tab-btn .icon {
    font-size: 1.25rem;
    transition: transform 0.3s ease;
}

.tab-btn:hover {
    color: var(--primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(129, 140, 248, 0.05));
    border-color: var(--primary-light);
}

.tab-btn:hover .icon {
    transform: scale(1.1);
}

.tab-btn.active {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-color: var(--primary);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

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

/* Content Area */
.content-body {
    flex: 1;
    padding: 3rem;
    overflow-y: auto;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.tab-panel {
    display: none;
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Formatting for Generated Content */
.prose {
    font-size: 1.0625rem;
    line-height: 1.75;
}

.prose h3 {
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
    color: var(--primary);
    font-size: 1.75rem;
    font-weight: 700;
    position: relative;
    padding-left: 1rem;
}

.prose h3::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.25rem;
    bottom: 0.25rem;
    width: 4px;
    background: linear-gradient(180deg, var(--primary), var(--primary-light));
    border-radius: 2px;
}

.prose h4 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-main);
    font-size: 1.375rem;
    font-weight: 600;
}

.prose p {
    margin-bottom: 1.5rem;
    line-height: 1.8;
    color: var(--text-main);
}

.prose ul,
.prose ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

body.rtl .prose ul,
body.rtl .prose ol {
    padding-left: 0;
    padding-right: 2rem;
}

.prose li {
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.prose strong {
    color: var(--primary);
    font-weight: 600;
}

.prose table {
    width: 100%;
    margin: 2rem 0;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.prose th,
.prose td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.prose th {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    font-weight: 600;
}

.prose tr:last-child td {
    border-bottom: none;
}

/* Summary Cards */
.summary-item {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.25rem;
    border-left: 5px solid var(--secondary);
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.summary-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.03), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.summary-item:hover {
    transform: translateX(8px);
    box-shadow: var(--shadow-lg);
}

.summary-item:hover::before {
    opacity: 1;
}

.summary-icon {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
}

body.rtl .summary-item {
    border-left: none;
    border-right: 5px solid var(--secondary);
}

body.rtl .summary-item:hover {
    transform: translateX(-8px);
}

/* Key Terms Grid */
.terms-search {
    margin-bottom: 2rem;
}

#term-search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

#term-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), var(--shadow-md);
}

.terms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.term-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.term-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.term-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-light);
}

.term-card:hover::before {
    transform: scaleX(1);
}

.term-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.75rem;
    font-size: 1.125rem;
}

.term-definition {
    font-size: 0.9375rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Quiz Styles */
.question-block {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    border: 2px solid var(--border);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

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

.question-text {
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    line-height: 1.5;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-label {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-card);
    font-weight: 500;
}

.option-label:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(129, 140, 248, 0.05));
    border-color: var(--primary-light);
    transform: translateX(4px);
}

.option-label input {
    margin-right: 1rem;
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary);
    cursor: pointer;
}

body.rtl .option-label input {
    margin-right: 0;
    margin-left: 1rem;
}

.quiz-submit-btn {
    width: 100%;
    margin-top: 2.5rem;
    padding: 1.25rem;
    font-size: 1.125rem;
}

.quiz-results {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    margin: 2rem 0;
}

.score-circle {
    display: inline-block;
    margin: 2rem 0;
}

#score-val {
    font-size: 5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 8px rgba(99, 102, 241, 0.2);
}

#score-msg {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin: 1.5rem 0;
}

/* Footer Navigation */
.unit-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: 1rem;
    padding: 2rem;
    border-top: 2px solid var(--border);
}

/* Buttons */
.btn {
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
}

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

.btn-outline,
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border: 2px solid var(--border);
}

.btn-outline:hover,
.btn-secondary:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(129, 140, 248, 0.05));
    transform: translateY(-2px);
}

.btn-outline:disabled,
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-success {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
    color: white;
}

.btn-success:hover {
    box-shadow: var(--shadow-lg), 0 0 20px rgba(16, 185, 129, 0.3);
    transform: translateY(-2px);
}

/* Utility */
.hidden {
    display: none !important;
}

.flex-spacer {
    flex: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        height: 100%;
        transform: translateX(-100%);
    }

    body.rtl .sidebar {
        transform: translateX(100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-menu-btn {
        display: block;
    }

    .unit-header {
        padding-top: 3.5rem;
    }

    .tabs-nav {
        gap: 1rem;
        padding: 0 1rem;
    }

    .tab-btn span.icon {
        font-size: 1.2rem;
    }

    .tab-btn {
        font-size: 0.9rem;
    }

    .unit-footer {
        flex-direction: column;
        gap: 1rem;
    }

    .unit-footer button {
        width: 100%;
    }
}

/* Selection Popup Styles - Professional */
.selection-popup {
    position: absolute;
    background: #09090b;
    /* Deep Black for high contrast aesthetics */
    color: #ffffff;
    padding: 6px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    /* Tighter gap */
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1);
    z-index: 9999;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 0.85rem;
    pointer-events: auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.selection-popup.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(0.95);
}

/* Tooltip Arrow */
.selection-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #09090b transparent transparent transparent;
}

.icon-btn {
    background: transparent;
    border: none;
    color: #e4e4e7;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.08);
}

.divider {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 4px;
}