/**
 * JBA Admin Dashboard - Advanced Component Styles
 *
 * Styles for modal, data-table, form-field, and other advanced components
 */

/* ============================================================================
   Modal Component
   ============================================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

.modal-overlay.show {
    opacity: 1;
}

.modal-dialog {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.3s ease;
    width: 100%;
}

.modal-dialog.show {
    transform: scale(1);
    opacity: 1;
}

/* Modal Sizes */
.modal-small {
    max-width: 400px;
}

.modal-medium {
    max-width: 600px;
}

.modal-large {
    max-width: 900px;
}

.modal-full {
    max-width: 95vw;
    max-height: 95vh;
}

.modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 90vh;
    overflow: hidden;
}

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

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-dark);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* ============================================================================
   Data Table Component
   ============================================================================ */

.data-table-container {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.table-search {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.table-search input {
    width: 100%;
}

.table-bulk-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--gray-50);
    border-bottom: 2px solid var(--border-color);
}

.table-header-cell {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.table-header-cell.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.table-header-cell.sortable:hover {
    background: var(--gray-100);
}

.table-header-cell .sort-icon {
    color: var(--text-light);
    margin-left: 0.25rem;
    font-size: 0.75rem;
}

.table-header-cell .sort-icon.active {
    color: var(--primary-color);
}

.table-cell-checkbox {
    width: 40px;
    text-align: center;
    padding: 0.75rem 0.5rem;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table tbody tr.selected {
    background: var(--danger-light);
}

.data-table tbody tr.clickable {
    cursor: pointer;
}

.table-cell {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text-dark);
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-light);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.page-size-selector select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.875rem;
}

.pagination-buttons {
    display: flex;
    gap: 0.25rem;
}

/* ============================================================================
   Form Field Component
   ============================================================================ */

.form-field {
    margin-bottom: 1rem;
}

.form-field.has-error .form-input,
.form-field.has-error .form-select,
.form-field.has-error .form-textarea {
    border-color: var(--danger);
}

.form-field.has-error .form-label {
    color: var(--danger);
}

.form-field.is-disabled {
    opacity: 0.6;
    pointer-events: none;
}

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-dark);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

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

.form-input::placeholder {
    color: var(--text-light);
}

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

.form-checkbox,
.form-radio {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
    cursor: pointer;
    accent-color: #C8102E;
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-dark);
    cursor: pointer;
    user-select: none;
}

.checkbox-label:hover,
.radio-label:hover {
    color: var(--text-dark);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-help-text {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

.field-error {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--danger);
    font-weight: 500;
}

/* ============================================================================
   Toast Notifications (Enhanced)
   ============================================================================ */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}

.toast {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.05);
    border-left: 4px solid;
    transform: translateX(calc(100% + 2rem));
    transition: all 0.3s ease;
    animation: slideInRight 0.3s ease forwards;
}

@keyframes slideInRight {
    to {
        transform: translateX(0);
    }
}

.toast-success {
    border-left-color: #10b981;
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-warning {
    border-left-color: #f59e0b;
}

.toast-info {
    border-left-color: #3b82f6;
}

.toast-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-dark);
    line-height: 1.5;
}

.toast-close {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.toast-close:hover {
    color: var(--text-dark);
}

/* ============================================================================
   Loading Spinner (Enhanced)
   ============================================================================ */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-100);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

/* ============================================================================
   Members View Styles
   ============================================================================ */

.members-view {
    padding: 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.page-header p {
    margin: 0.25rem 0 0;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
}

.filters-bar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

/* Flexbox utilities */
.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

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

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

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

/* 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-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Spacing utilities */
.space-y-4 > * + * {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mt-3 {
    margin-top: 0.75rem;
}

.mr-2 {
    margin-right: 0.5rem;
}

.mr-auto {
    margin-right: auto;
}

.py-8 {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* Text utilities */
.text-center {
    text-align: center;
}

.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
}

.text-2xl {
    font-size: 1.5rem;
    line-height: 2rem;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.font-mono {
    font-family: ui-monospace, monospace;
}

/* Color utilities */
.text-gray-500 {
    color: var(--text-light);
}

.text-gray-600 {
    color: var(--text-dark);
}

.text-gray-700 {
    color: var(--text-dark);
}

.text-gray-900 {
    color: var(--text-dark);
}

.text-red-500 {
    color: var(--danger);
}

.text-red-600 {
    color: #dc2626;
}

.text-red-900 {
    color: #7f1d1d;
}

.text-green-600 {
    color: #16a34a;
}

.text-green-800 {
    color: #166534;
}

.text-blue-600 {
    color: #2563eb;
}

.text-yellow-800 {
    color: #854d0e;
}

.text-purple-600 {
    color: #9333ea;
}

/* Background utilities */
.bg-green-100 {
    background-color: #dcfce7;
}

.bg-red-50 {
    background-color: #fef2f2;
}

.bg-red-100 {
    background-color: #fee2e2;
}

.bg-yellow-100 {
    background-color: #fef3c7;
}

.bg-gray-100 {
    background-color: #f3f4f6;
}

/* Border utilities */
.border {
    border-width: 1px;
}

.border-red-200 {
    border-color: #fecaca;
}

.rounded {
    border-radius: 0.25rem;
}

.rounded-text {
    border-radius: 0.125rem;
}

/* Layout utilities */
.p-3 {
    padding: 0.75rem;
}

.px-2 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.py-1 {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

/* Responsive utilities */
@media (min-width: 768px) {
    .md\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .modal-dialog {
        margin: 1rem;
    }

    .modal-large,
    .modal-full {
        max-width: 100%;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }

    .table-pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination-controls {
        flex-direction: column;
    }

    .pagination-buttons {
        flex-wrap: wrap;
    }
}

/* ============================================================================
   Button Variants (Enhanced)
   ============================================================================ */

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1.125rem;
}

.btn-outline-primary {
    background: var(--card-bg);
    color: #C8102E;
    border: 2px solid #C8102E;
}

.btn-outline-primary:hover {
    background: #C8102E;
    color: white;
}

.btn-success {
    background: #10b981;
    color: white;
    border: none;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: #f59e0b;
    color: white;
    border: none;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
}

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

/* ============================================================================
   Dropdown Menu
   ============================================================================ */

.dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    margin-top: 4px;
    z-index: 1000;
    overflow: hidden;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: var(--card-bg);
    border: none;
    text-align: left;
    font-size: 14px;
    color: var(--text-dark);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dropdown-item:hover {
    background: var(--gray-100);
}

.dropdown-item span {
    font-size: 16px;
}

.dropdown-item-danger {
    color: #dc2626;
}

.dropdown-item-danger:hover {
    background: #fef2f2;
}

/* ============================================================================
   Dark Mode Support (Optional)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed */
}
