/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--primary-font);
    font-size: var(--font-size-base);
    background: var(--main-background);
    direction: rtl;
    height: 100vh;
    overflow: hidden;
    color: var(--text-primary);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Top Bar */
.top-bar {
    height: 16.67vh;
    background: var(--bar-background);
    color: var(--bar-text-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: var(--box-shadow-light);
    z-index: 1000;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.top-bar-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.top-bar-center .app-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    text-align: center;
}

.system-logo-section {
    display: flex;
    align-items: center;
    gap: 150px;
}

.system-logo {
    width: 50px;
    height: 50px;
}

.system-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.system-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.app-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: 2px;
}

.system-version {
    font-size: var(--font-size-small);
    opacity: var(--bar-text-opacity);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.entity-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.entity-logo {
    width: 45px;
    height: 45px;
    background: var(--bar-hover-background);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid var(--bar-border-color);
    transition: var(--button-transition);
}

.entity-logo:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.entity-logo:active {
    transform: scale(0.98);
}

.entity-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.entity-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.entity-name {
    font-size: var(--font-size-medium);
    font-weight: 600;
    margin-bottom: 2px;
}

.entity-type {
    font-size: var(--font-size-small);
    opacity: var(--bar-text-opacity);
}

.user-section {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: var(--button-padding);
    /*background: var(--bar-hover-background);
    border-radius: var(--border-radius);
    border: 1px solid var(--bar-border-color);*/
}

.user-name {
    font-weight: 600;
    font-size: var(--font-size-base);
    margin-bottom: 2px;
}

.user-role {
    opacity: var(--bar-text-opacity);
    font-size: var(--font-size-small);
}

.logout-btn {
    background: var(--bar-hover-background);
    border: 1px solid var(--bar-border-color);
    color: var(--bar-text-color);
    padding: var(--button-padding);
    border-radius: var(--button-border-radius);
    cursor: pointer;
    transition: var(--button-transition);
    font-size: var(--font-size-base);
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* System Footer */
.system-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bar-background);
    color: var(--bar-text-color);
    padding: 2px 15px;
    text-align: center;
    font-size: 16px;
    border-top: 1px solid #444;
    z-index: 999;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.footer-content {
    direction: rtl;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.footer-content .system-logo {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.footer-content .system-logo img {
    height: 40px;
    width: auto;
}

#systemVersion {

    color: var(--bar-text-color);
}


/* Main Container */
.main-container {
    display: flex;
    background: var(--main-background);
    flex-direction: row-reverse;
    gap: 20px;
    direction: rtl;
    width: 100%;
    min-height: calc(100vh - var(--top-bar-height-minimal) - 50px);
    /* Accounts for top bar and footer - min-height allows growth */
    overflow: visible;
    margin-bottom: 0;
}

/* Side Menu */
.side-menu {
    width: 12.5vw;
    background: var(--menu-background);
    box-shadow: var(--box-shadow-light);
    transition: var(--button-transition);
    overflow-y: auto;
    z-index: 100;
}

.side-menu.collapsed {
    width: 60px;
}

.menu-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.menu-title {
    font-size: var(--font-size-large);
    font-weight: 600;
    color: var(--text-primary);
    transition: opacity 0.3s ease;
}

.side-menu.collapsed .menu-title {
    opacity: 0;
    pointer-events: none;
}

.menu-section-title {
    padding: 15px 20px 10px;
    font-size: var(--font-size-small);
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: opacity 0.3s ease;
}

.side-menu.collapsed .menu-section-title {
    opacity: 0;
    pointer-events: none;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    transition: transform 0.3s ease;
    padding: 8px;
    border-radius: 4px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-toggle:hover {
    background: #f0f0f0;
    color: var(--text-primary);
}

.menu-toggle:active {
    background: #e0e0e0;
}

.side-menu.collapsed .menu-header {
    justify-content: flex-end;
    position: relative;
}

.side-menu.collapsed .menu-toggle {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%) rotate(180deg);
    z-index: 2;
}

.menu-items {
    padding: 10px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--button-transition);
    border-right: 3px solid transparent;
}

.menu-item:hover {
    background: var(--hover-background);
    color: var(--text-accent);
    border-right-color: var(--active-border);
}

.menu-item.active {
    background: var(--hover-background);
    color: var(--text-accent);
    border-right-color: var(--active-border);
    font-weight: 600;
}

.menu-item-icon {
    font-size: var(--font-size-large);
    margin-left: 12px;
    min-width: 20px;
}

.menu-item-text {
    transition: opacity 0.3s ease;
}

.side-menu.collapsed .menu-item-text {
    opacity: 0;
    pointer-events: none;
}

.side-menu.collapsed .menu-item {
    justify-content: center;
    padding: 12px 20px;
}

/* Main Content */
.main-content {
    order: 1;
    flex: 1;
    background: var(--main-background);
    padding: 30px;
    /* 
     * Generic solution: Large bottom padding ensures content clears the fixed footer
     * when cards/sections expand. This works for all pages without page-specific logic.
     * Calculation: footer (50px) + safety margin (100px) + expansion buffer (50px) = 200px
     */
    padding-bottom: 200px !important;
    overflow-y: auto;
    overflow-x: hidden;
}

#dynamicContent {
    display: flex;
    flex-direction: row-reverse;
    gap: 20px;
    min-height: 100%;
    align-items: flex-start;
    /* Add bottom margin to ensure scroll can reach all content */
    margin-bottom: 150px;
}

.content-header {
    margin-bottom: 30px;
}

.page-title-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 8px;
    gap: 20px;
}

.page-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-align: right;
    flex: 1;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: var(--font-size-medium);
}

.left-spacer {
    flex: 1;
  visibility: hidden; /* Makes the third part invisible */
}

.header-actions {

    align-items: left;
    display: flex;
    padding-bottom: 15px;
}

.content-card {
    background: var(--card-background);
    border-radius: var(--border-radius-large);
    padding: 20px;
    box-shadow: var(--box-shadow-medium);
    margin-bottom: 10px;
    /* Use flex to grow and fill available height */
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: visible;
}

/* Dashboard */
.dashboard-grid {
    display: flex;
    flex-direction: row;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
}

.dashboard-card {
    background: var(--card-background);
    border-radius: var(--border-radius-large);
    padding: 24px;
    box-shadow: var(--box-shadow-medium);
    text-align: center;
    transition: var(--button-transition);
    width: 312px;
    min-width: 312px;
    max-width: 312px;
    /* Dynamic height based on screen size - increased for more content */
    min-height: 350px;
    height: calc(100vh - 220px);
    /* Reduced from 280px to 220px for taller cards */
    max-height: calc(100vh - 180px);
    /* Reduced from 200px to 180px */
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.internal-card {
    background: var(--secondary-background);
    border: 1px solid #000000;
    /* Black border as requested */
    border-radius: var(--border-radius);
    padding: 12px;
    font-size: 11pt;
    font-family: inherit;
    text-align: left;
    /* Changed to left alignment */
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.internal-cards-container {
    flex: 1;
    margin-top: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* Reduced from 8px to 6px for tighter spacing */
    padding: 0 4px;
}

.internal-card:hover {
    background: var(--hover-background);
    border-color: #000000;
    /* Keep black border on hover */
}

.internal-card-timestamp {
    color: var(--text-muted);
    font-size: 9pt;
    margin-top: 6px;
    text-align: right;
    /* Keep timestamps left aligned */
}

.internal-card-content {
    color: var(--text-secondary);
    font-size: 10pt;
    line-height: 1.3;
    text-align: right;
    /* Left alignment for content */
}

/* ✅ New card header layout with date and entity */
.internal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color-light, #e0e0e0);
}

.internal-card-date {
    color: var(--text-muted, #6c757d);
    font-size: 9pt;
    font-weight: 600;
}

.internal-card-entity {
    color: var(--primary-color, #0d6efd);
    font-size: 9pt;
    font-weight: 500;
}



.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--box-shadow-strong);
}

.dashboard-card-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 8px;
    /* Reduced space between title and card border */
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.dashboard-card-icon {
    font-size: 16pt;
    margin-right: 8px;
    /* RTL spacing */
    flex-shrink: 0;
}

.dashboard-card-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16pt;
    margin: 0;
    flex: 1;
    text-align: right;
    /* RTL alignment */
}

.dashboard-card-plus {
    width: 20px;
    height: 20px;
    margin-left: auto;
    /* Push to leftmost position in RTL */
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}


/* Bold styling for new/unread alerts and events */
.internal-card.alert-new .internal-card-content {
    font-weight: 700;
    color: var(--text-primary, #212529);
}

.internal-card.alert-new {
    border-right: 3px solid var(--primary-color, #0d6efd);
}

/* Optional: Add visual indicator for unread */
.internal-card.alert-new::before {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background-color: var(--primary-color, #0d6efd);
    border-radius: 50%;
}

/* Ensure proper positioning for indicator */
.internal-card {
    position: relative;
    padding-right: 24px; /* Make room for indicator */
}

.dashboard-card-plus:hover {
    opacity: 1;
    transform: scale(1.1);
}

.dashboard-flex-row {
    display: flex;
    align-items: flex-start;
    gap: 32px;
    margin-bottom: 15px;
    /* 15px from bottom as requested */
    max-width: 1200px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    justify-content: space-between;
    /* Calculate height to reach 15px from bottom */
    height: calc(100vh - 16.67vh - 60px - 15px);
    /* Total height - top bar - padding - bottom margin */
    min-height: 400px;
    /* Minimum height for usability */
}

/* Add dashboard cards wrapper to contain the cards */
.dashboard-cards-wrapper {
    order: 1;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
    /* Prevent overflow */
    align-items: flex-start;
    /* Align cards to top */

}

/* Context Buttons */
.context-buttons-section {
    order: 2;
    width: 180px;
    min-width: 180px;
    /* Ensure it doesn't shrink */
    max-width: 180px;
    /* Prevent it from growing */
    height: 260px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 18px;
    padding: 18px 8px;
    box-sizing: border-box;
    /*background: var(--context-section-background);
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow-light);
    margin: 24px 0 0 0;
    /* Remove right margin to align with edge */
    flex-shrink: 0;
    /* Prevent shrinking */
}

/* ✅ Context button styles moved to ui-components.css - DO NOT duplicate here */

/* Tables */
.attributes-table,
.reusable-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: var(--card-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow-light);
}

.attributes-table th,
.table-header {
    background: var(--table-header-background);
    color: var(--table-header-text);
    padding: 12px 15px;
    text-align: right;
    font-weight: 600;
    border-bottom: 2px solid var(--table-header-border);
    position: relative;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.column-title {
    cursor: pointer;
    flex: 1;
}

.column-title:hover {
    text-decoration: underline;
}

.sort-icon {
    font-size: var(--font-size-small);
    min-width: 12px;
}

.filter-icon {
    cursor: pointer;
    font-size: var(--font-size-base);
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.filter-icon:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.filter-icon.filtered {
    background-color: #ff6b6b;
    color: var(--button-text-color);
}

.attributes-table td,
.reusable-table td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid var(--border-color-light);
    vertical-align: top;
}

.attributes-table tr:nth-child(even),
.reusable-table tr:nth-child(even) {
    background-color: var(--hover-background);
}

.attributes-table tr:hover,
.reusable-table tr:hover {
    background-color: var(--hover-background-light);
}

.table-input {
    width: 100%;
    border: 1px solid #ddd;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: var(--font-size-base);
    direction: rtl;
    font-family: var(--primary-font);
}

.table-input:focus {
    outline: none;
    border-color: var(--input-focus-color);
    box-shadow: var(--input-focus-shadow);
}

.readonly-cell {
    background-color: #f5f5f5;
}

/* Filter Menu */
.filter-menu {
    background: var(--card-background);
    border: 1px solid #ddd;
    border-radius: var(--button-border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
    direction: rtl;
}

.filter-option {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-option:hover {
    background-color: var(--hover-background-light);
}

.filter-option.clear-filter {
    color: #ff6b6b;
    font-weight: bold;
    border-bottom: 1px solid var(--border-color-light);
    margin-bottom: 4px;
}

.filter-option.clear-filter:hover {
    background-color: #ffe6e6;
}

.filter-menu hr {
    margin: 4px 0;
    border: none;
    border-top: 1px solid var(--border-color-light);
}

/* Empty States */
.attributes-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-style: italic;
}

/* School Year Page Layout */
.schoolyear-container {
    display: flex;
    gap: 20px;
    height: 100%;
    direction: rtl;
    width: 100%;
}

.schoolyear-content {
    flex: 1;
    min-width: 0;
    /* Prevents flex item from overflowing */
    width: calc(100% - 200px);
    /* Main content minus context buttons width */
    max-width: calc(100% - 200px);
}

.schoolyear-content .content-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.schoolyear-context {
    order: 2;
    /* Places it on the right in RTL */
    width: 180px;
    min-width: 180px;
    max-width: 180px;
    height: 260px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 18px;
    padding: 18px 8px;
    box-sizing: border-box;
    background: var(--context-section-background);
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow-light);
    margin: 0;
    position: sticky;
    top: 20px;
    flex-shrink: 0;
    /* Prevent context buttons from shrinking */
}

/*.schoolyear-context .context-btn {
    width: 100%;
    min-width: 100px;
    height: 48px;
    border-radius: var(--border-radius);
    font-size: var(--font-size-medium);
    font-weight: 600;
    cursor: pointer;
    transition: var(--button-transition);
    box-shadow: var(--box-shadow-light);
    margin: 0 !important;
    /* Override inline styles 
}*/



/* Ensure content doesn't overflow */
.schoolyear-content * {
    max-width: 100%;
    box-sizing: border-box;
}

#schoolYearSectionContent .content-card {
    width: 100%;
    max-width: 100%;
}

/* Students Page Styles */
/* main-container defined globally above - do not duplicate */

.students-content {
    flex: 1;
    min-width: 0;
    /* Allow content to use full available width */
    width: 100%;
    max-width: 100%;
}



/* ✅ Context button styles in ui-components.css - DO NOT override here */

/* Students Summary Cards */
.students-summary {
    margin-bottom: 30px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 190px);
    gap: 0;
    margin-bottom: 30px;
    direction: rtl;
    justify-content: start;
}

.summary-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.summary-icon-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    opacity: 0.8;
}

.summary-info {
    flex: 1;
    text-align: right;
}

.summary-value {
    font-size: 2em;
    font-weight: 700;
    color: var(--color-secondary);
    line-height: 1;
    margin-bottom: 5px;
}

.summary-label {
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

/* Global Table Styling with Gridlines - Apply to ALL ReusableTable instances */
.table-container {
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: white;
    direction: rtl;
    width: fit-content;
    max-width: 100%;
}

.data-table {
    width: auto;
    min-width: auto;
    border-collapse: collapse;
    direction: rtl;
    text-align: right;
    font-family: var(--primary-font);
}

.data-table th {
    background-color: #f8f9fa;
    color: #333;
    font-weight: 600;
    padding: 15px 12px;
    border-bottom: 2px solid #dee2e6;
    border-left: 1px solid #dee2e6;
    white-space: nowrap;
    font-size: 0.95em;
    text-align: right;
}

.data-table th:first-child {
    border-right: none;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    border-left: 1px solid #dee2e6;
    vertical-align: middle;
    text-align: right;
}

.data-table td:first-child {
    border-right: none;
    background-color: #f8f9fa;
    font-weight: 500;
    direction: ltr;
    text-align: right;
}

.data-table tr:hover {
    background-color: #f5f5f5;
}

.data-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.data-table td:nth-child(3) {
    font-weight: 600;
    color: #2c3e50;
}

/* Right-align table cells except actions column */
.data-table td,
.data-table th {
    text-align: right;
}

.data-table td:last-child,
.data-table th:last-child {
    text-align: center;
    /* Actions column centered */
}

/* Loading and Error States */
.loading-spinner {
    text-align: center;
    padding: 40px 20px;
    direction: rtl;
    font-size: 1.1em;
    color: #666;
}

.table-error {
    text-align: center;
    padding: 40px 20px;
    direction: rtl;
    font-size: 1.1em;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
}

.table-error button {
    margin-top: 15px;
    padding: 8px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.table-error button:hover {
    background-color: #0056b3;
}

/* Detail cards styling 
.detail-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
}*/

/*.detail-card-header {
    background: #e9ecef;
    padding: 5px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    min-height: 10px;
    border-bottom: 2px solid #dee2e6;
}

.detail-card-header:hover {
    background: linear-gradient(135deg, #b7cdf3 0%, #95a1b8 100%);
}

.detail-card-title {
    margin: 0;
    color: #333;
    font-size: 1.1em;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50ch;
    /* 50 character limit 
    padding-right: 10px;
}

.card-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.collapse-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    line-height: 1;
    border-radius: 4px;
    flex-shrink: 0;
}

.collapse-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.detail-card.collapsed .collapse-toggle {
    transform: rotate(0deg);
}

.detail-card.expanded .collapse-toggle {
    transform: rotate(90eg);
}


.detail-card-content {
    padding: 10px;
    background: white;
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    direction: rtl;
}

.detail-card.collapsed .detail-card-content {
    max-height: 0;
    padding: 0 20px;
}*/

/* Ensure action buttons don't interfere with collapse toggle 
.detail-card-header .btn-icon {
    z-index: 2;
    position: relative;
    flex-shrink: 0;
}
*/
/* Enhanced detail card content for table containers following Table Horizontal Scrolling 
.detail-card-content {
    padding: 10px;
    background: white;
    min-height: 75px;
    color: #6c757d;
    direction: rtl;
    overflow-x: auto; // Enable horizontal scroll for card content 
}*/

/* Generic Detail Fields - System-wide styling */
.detail-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    direction: rtl;
    display: flex;
}

.detail-section {
    background: #f9f9f9;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.detail-section-title {
    color: var(--color-secondary);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--color-secondary);
    padding-bottom: 5px;
    font-size: 1.1em;
    font-weight: 600;
}

.detail-field {
    margin: 8px 0;
    line-height: 1.2;
}

.detail-field-label {
    color: #333;
    font-weight: 600;
    margin-left: 8px;
}

.detail-field-value {
    color: #666;
}

.form-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.95em;
    font-family: inherit;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Inline form input styles moved to ui-components.css */

.detail-status-active {
    color: var(--status-active);
    font-weight: 600;
}

.detail-status-inactive {
    color: var(--status-inactive);
    font-weight: 600;
}

.detail-timestamp {
    font-size: 0.9em;
    color: #6c757d;
    margin-top: 10px;
}

/* Action Icons - Ensure proper sizing and isolation */
.action-icon-natural {
    width: 15px;
    height: 15px;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
}

.btn-icon {
    padding: 4px 6px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background-color: transparent;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon img {
    width: 15px;
    height: 15px;
    object-fit: contain;
}

/* Ensure table cells don't override icon sizing */
.actions-cell {
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: center;
}

.actions-cell .btn-icon {
    padding: 4px 6px;
}

.actions-cell .action-icon-natural {
    width: 15px !important;
    height: 15px !important;
}

/* School Attributes Styles */
.attributes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    direction: rtl;
}

.attribute-item {
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    min-height: 75px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attribute-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
    cursor: pointer;
}

.attribute-value-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

.attribute-suffix {
    font-size: 0.85em;
    color: #6c757d;
    white-space: nowrap;
}

/* School Attributes Editable Styles */
.attribute-input,
.attribute-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.95em;
    font-family: inherit;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.attribute-input:focus,
.attribute-select:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.attribute-input:disabled,
.attribute-select:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* Hebrew RTL support for select dropdown */
.attribute-select {
    direction: rtl;
    text-align: right;

    padding-right: 8px;
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
}

.attribute-select option {
    direction: rtl;
    text-align: right;
}

/* Checkbox styling for boolean attributes */
.attribute-checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    direction: rtl;
}

.attribute-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
}

.attribute-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.attribute-checkbox-label {
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.attribute-checkbox:checked+.attribute-checkbox-label {
    color: #28a745;
}

.attribute-checkbox:not(:checked)+.attribute-checkbox-label {
    color: #dc3545;
}

/* Number input for integer attributes */
.attribute-input[type="number"] {
    text-align: right;
}

.attribute-input[type="number"]::-webkit-inner-spin-button,
.attribute-input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    margin-left: 8px;
}

/* School Attributes Dialog Overlays */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    direction: rtl;
}

.dialog-box {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    text-align: center;
}

.dialog-title {
    margin-bottom: 20px;
    color: #333;
}

.dialog-title.warning {
    color: #dc3545;
}

.dialog-message {
    margin-bottom: 30px;
    color: #6c757d;
    font-size: 16px;
}

.dialog-message.warning {
    color: #333;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.dialog-btn {
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: var(--font-size-base);
    font-weight: 600;
    transition: all 0.3s ease;
}

.dialog-btn.save {
    background: linear-gradient(135deg, var(--color-success) 0%, #20873b 100%);
    color: white;
}

.dialog-btn.save:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
}

.dialog-btn.dont-save {
    background: linear-gradient(135deg, var(--color-danger) 0%, #bb2d3b 100%);
    color: white;
}

.dialog-btn.dont-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(220, 53, 69, 0.3);
}

.dialog-btn.cancel {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
}

.dialog-btn.cancel:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(108, 117, 125, 0.3);
}

.dialog-btn.stay {
    background: linear-gradient(135deg, var(--button-primary-color) 0%, var(--button-primary-hover) 100%);
    color: white;
}

.dialog-btn.stay:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.dialog-btn.leave {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
}

.dialog-btn.leave:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(108, 117, 125, 0.3);
}


.autocomplete-arrow {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #6b7280;
    pointer-events: none;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

/* Rotate arrow when dropdown is open */
.autocomplete-dropdown.show ~ .autocomplete-arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* School Classes Edit Mode - Select Dropdown Styling */
.class-row select.class-level,
#classesTableContainer select[data-field="level"] {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--button-border-radius);
    text-align: right;
    font-family: var(--primary-font);
    font-size: var(--font-size-base);
    direction: rtl;
    background-color: white;
    cursor: pointer;
    width: 100%;
}

.class-row select.class-level:focus,
#classesTableContainer select[data-field="level"]:focus {
    outline: none;
    border-color: var(--input-focus-color);
    box-shadow: var(--input-focus-shadow);
}



.class-row select.class-level option,
#classesTableContainer select[data-field="level"] option {
    padding: 8px;
    font-family: Arial, sans-serif;
    direction: rtl;
}

/* Delete button styling */
.dialog-btn.delete {
    background-color: #dc3545;
    color: white;
}

.dialog-btn.delete:hover {
    background-color: #c82333;
}

/* Warning dialog title */
.dialog-title.warning {
    color: #856404;
}

* Inline edit button for detail fields */ .btn-icon-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 4px;
    margin-left: 8px;
    /* border: 1px solid #dee2e6;
    border-radius: 4px; */
    background-color: transparent;
    cursor: pointer;
    vertical-align: middle;
    transition: all 0.2s ease;
}

.btn-icon-inline:hover {
    background-color: #f8f9fa;
    border-color: #0d6efd;
    transform: scale(1.05);
}

.btn-icon-inline:active {
    background-color: #e9ecef;
    transform: scale(0.98);
}


/* Upload Section Styling */
.upload-section {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
}

.upload-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 18px;
}

.upload-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.form-group input,
.form-group select {
    padding: 2px 2px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.form-group input[type="file"] {
    padding: 6px;
}

/* Form row for side-by-side fields */
.form-row {
    display: flex;
    gap: 15px;
    width: 100%;
    margin-bottom: 15px;
}

.form-row .form-col {
    flex: 1;
    min-width: 0; /* Prevents flex items from overflowing */
}

/* Ensure form-group inside form-col doesn't add extra margin */
.form-row .form-col .form-group {
    width: 100%;
    margin-bottom: 0;
}

.form-row .form-col input,
.form-row .form-col select {
    width: 100%;
    box-sizing: border-box;
}

.btn-upload {
    padding: 10px 20px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: center;
}

.btn-upload:hover {
    background-color: #218838;
}

.btn-upload:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.65;
}

.documents-table-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .upload-form {
        grid-template-columns: 1fr;
    }
}

/* Modal styles are in ui-components.css */

.action-item {
    padding: 10px;
    margin: 5px 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: move;
    transition: all 0.2s;
    direction: rtl;
    text-align: right;
}

.action-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.action-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.action-item-type {
    font-size: 11px;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
}

.action-item-name {
    font-size: 14px;
    font-weight: 500;
    margin: 4px 0;
}

.action-item-reference {
    font-size: 12px;
    color: #495057;
}

.drop-zone-active {
    background-color: #e7f3ff !important;
    border-color: #007bff !important;
}

/* Upload status styles */
.upload-status {
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    direction: rtl;
    text-align: right;
    white-space: pre-wrap;
}

.upload-status-loading {
    background-color: #cfe2ff;
    color: #084298;
    border: 1px solid #b6d4fe;
}

.upload-status-success {
    background-color: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

.upload-status-error {
    background-color: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

/* Mapping table styles */
.mapping-table {
    font-size: 14px;
}

.mapping-table select {
    direction: rtl;
    text-align: right;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    appearance: none;
    border-radius: 0.25rem;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.form-control:focus {
    color: #212529;
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, .25);
}

/* File input wrapper for Hebrew button */
.file-input-wrapper {
    position: relative;
    width: 100%;
}

.btn-file-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    background-color: #f8f9fa;
    color: #495057;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    direction: rtl;
    font-weight: 500;
}

.btn-file-select:hover {
    border-color: #007bff;
    background-color: #e7f3ff;
    color: #007bff;
}

.btn-file-select span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dropdown arrow styling for mapping selects */
.mapping-select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23495057' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 8px center;
    background-size: 16px;
    padding-right: 30px !important;
    cursor: pointer;
}

.mapping-select:focus {
    border-color: var(--input-focus-color);
    outline: none;
    box-shadow: var(--input-focus-shadow);
}

/* Time Spinner Styles */
.time-spinner-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: all 0.2s;
}

.time-spinner-btn:hover {
    background: #e9ecef;
    border-color: #007bff;
}

.time-spinner-btn:active {
    background: #dee2e6;
}

.time-input {
    width: 50px;
    padding: 8px;
    text-align: center;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    margin: 4px 0;
}

.time-separator {
    font-size: 24px;
    font-weight: bold;
    color: #495057;
    line-height: 1;
}

/* ✅ Modal Styles for Alerts/Events */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    direction: rtl;
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10x;
    border-bottom: 1px solid #dee2e6;
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
}

.modal-close:hover,
.modal-close:focus {
    color: #000;
}

.modal-body {
    padding: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    margin-top: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #0b5ed7;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: #5c636a;
}

.d-flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.align-center {
    align-items: center;
}

.gap-2 {
    gap: 8px;
}

/* ============================================
   DEPRECATED BUTTON STYLES (Use ui-components.css instead)
   These are kept for backward compatibility only
   ============================================ */