/* Utility helpers */
.hidden {
    display: none;
}

.section-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
}

.section-toggle .chevron {
    transition: transform 0.2s ease;
}

.section-toggle[data-collapsed="1"] .chevron {
    transform: rotate(-90deg);
}

/* Language Selector */
.language-selector {
    position: relative;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
    user-select: none;
}

.language-selector:hover {
    background-color: var(--hover-color, #f5f5f5);
}

.current-language {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 500;
}

.current-language:after {
    content: '▼';
    margin-left: 0.5rem;
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.language-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 1000;
}

.language-selector.active .language-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.language-selector.active .current-language:after {
    transform: rotate(180deg);
}

/* Smooth fade-out on close */
.language-selector.active.closing .language-options {
    opacity: 0;
    transform: translateY(-10px);
    visibility: visible; /* keep visible during transition */
}

.language-options a {
    display: block;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

.language-options a:last-child {
    border-bottom: none;
}

.language-options a:hover {
    background-color: var(--primary-silver, #f8f9fa);
}

.language-options a.active {
    background-color: var(--primary-cyan, #00B2CC);
    color: white;
}

/* Visual cue for active language option */
.language-options a.active::before {
    content: '✓';
    display: inline-block;
    margin-right: 0.5rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 2rem;
}

.card-footer {
    padding: 1rem 2rem;
    border-top: 1px solid var(--border-color);
    background: var(--primary-silver);
    border-radius: 0 0 12px 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    justify-content: center;
}

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

.btn-primary:hover {
    background: #009BB3;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Busy state spinner for buttons */
.btn[aria-busy="true"] {
    opacity: 0.9;
    cursor: progress;
}
.btn[aria-busy="true"]::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: kionov-spin .6s linear infinite;
}

@keyframes kionov-spin {
    to { transform: rotate(360deg); }
}

.btn-secondary {
    background: var(--text-gray);
    color: white;
}

.btn-secondary:hover {
    background: #374151;
}

.btn-outline {
    background: transparent;
    color: var(--primary-cyan);
    border: 1px solid var(--primary-cyan);
}

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

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

.btn-danger:hover {
    background: #dc2626;
}

/* Ghost/Icon buttons for toolbars and toggles */
.btn-ghost {
    background: transparent;
    border: none;
    color: inherit;
    padding: 0.5rem; /* override .btn padding for compact controls */
    border-radius: 8px;
}

.btn-ghost:hover {
    background: var(--primary-silver);
}

/* Ensure avatar button stays visible when no image is present */
.user-avatar.btn-ghost {
    /* Use background-color so inline background-image (when present) still shows */
    background-color: var(--primary-cyan);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* size driven by container-specific CSS */
}

/* Utilities (minimal set for inline-style cleanup) */
.ml-2 { margin-left: 0.5rem; }
.mr-2 { margin-right: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.w-full { width: 100%; }
.abs-tr-6 { position: absolute; right: 6px; top: 6px; }

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

/* Compact card variant: reduces paddings and table density for tighter UIs */
.card.compact .card-header { padding: 0.75rem 1rem; }
.card.compact .card-body { padding: 1rem 1.25rem; }
.card.compact .table th,
.card.compact .table td { padding: 0.5rem 0.5rem; }
.card.compact .btn.btn-sm { padding: 0.35rem 0.6rem; }

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary-cyan);
    box-shadow: 0 0 0 3px rgba(0, 178, 204, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-gray);
    margin-top: 0.25rem;
}

/* Validation states */
.form-input.error, .form-select.error, .form-textarea.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

.validation-error {
    color: var(--danger-color);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: none;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue { background: rgba(0, 178, 204, 0.1); color: var(--primary-cyan); }
.stat-icon.green { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-icon.red { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    color: var(--text-dark);
    line-height: 1;
}

/* Ensure numbers in tiles align right when used in card layouts */
.stat-card .stat-value { text-align: right; }

.stat-label {
    color: var(--text-gray);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table th {
    background: var(--primary-silver);
    color: var(--text-dark);
    font-weight: 600;
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: rgba(0, 178, 204, 0.05);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-info { background: rgba(0, 178, 204, 0.1); color: var(--primary-cyan); }
.badge-gray { background: rgba(107, 114, 128, 0.1); color: var(--text-gray); }

/* Progress Bars */
.progress {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-cyan);
    transition: width 0.3s ease;
}

/* Dropdowns */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 50;
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-dark);
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.dropdown-menu a:hover {
    background: var(--primary-silver);
}

.dropdown-menu hr {
    margin: 0.5rem 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

/* Notifications Dropdown */
.notifications-menu {
    width: 360px;
    max-width: 90vw;
    padding: 0;
}

.notifications-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.notifications-title {
    font-weight: 600;
}

.notifications-list {
    max-height: 320px;
    overflow: auto;
}

.notification-item {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.notification-item:hover { background: var(--primary-silver); }
.notification-item.unread { background: #fffdf7; }

.notification-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,178,204,0.1);
    color: var(--primary-cyan);
    font-size: 14px;
}

.notification-content {
    min-width: 0;
}

.notification-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-text {
    font-size: 0.85rem;
    color: var(--text-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Utility: single-line text truncation */
.truncate {
    display: block;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-meta {
    font-size: 0.75rem;
    color: var(--text-gray);
    text-align: right;
}

.notifications-footer {
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pagination .page-item { list-style: none; }

.pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 1rem;
    line-height: 1;
}

.pagination .page-item.active .page-link {
    background: var(--primary-cyan);
    border-color: var(--primary-cyan);
    color: #fff;
    font-weight: 600;
}

.pagination .page-item.disabled .page-link {
    opacity: 0.5;
    pointer-events: none;
    color: var(--text-gray);
}

.pagination .page-link:hover {
    border-color: var(--primary-cyan);
    background: var(--primary-silver);
}

/* Keyboard focus visibility */
.pagination .page-link:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 178, 204, 0.15);
}

.pagination .page-info { font-size: 0.85rem; color: var(--text-gray); }

/* Modals */
.modal {
    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;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-gray);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--primary-silver);
}

.modal-body {
    padding: 2rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    /* Ensure toasts appear above any modal/overlay */
    z-index: 20000;
}

.toast {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 400px;
    animation: toastSlideIn 0.3s ease forwards;
    position: relative;
}

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

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

.toast-icon {
    font-size: 1.25rem;
    margin-top: 0.125rem;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.toast-message {
    color: var(--text-gray);
    font-size: 0.875rem;
}

/* Toast close button */
.toast-close {
    margin-left: 0.25rem;
    background: transparent;
    border: none;
    color: var(--text-gray);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 4px;
}
.toast-close:hover {
    color: var(--text);
}

/* Generic Tabs */
.tab-content { min-height: 200px; }
.tab-pane { display: none; padding-top: 0.75rem; }
.tab-pane.active { display: block; }
