/* =============================================================================
   AMIP Shared Components CSS
   =============================================================================

   This file contains styles for all shared Elm components in Components/

   DO NOT add component-specific styles to other CSS files.
   All reusable component styles should be centralized here.

   Components:
   - Badge
   - LoadingState
   - EmptyState
   - ErrorState
   - StatCard
   - ActionCard
   ============================================================================= */

/* =============================================================================
   BADGE COMPONENT
   ============================================================================= */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    white-space: nowrap;
}

/* Variant badges */
.badge-default {
    background: var(--color-border, #e2e8f0);
    color: var(--color-text, #1e293b);
}

.badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

.badge-secondary {
    background: #f1f5f9;
    color: #475569;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-muted {
    background: #f1f5f9;
    color: #94a3b8;
}

/* =============================================================================
   LOADING STATE COMPONENT
   ============================================================================= */

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
}

.loading-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--color-border, #e2e8f0);
    border-top-color: var(--color-primary, #2563eb);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-message {
    font-size: 0.875rem;
    color: var(--color-text-muted, #64748b);
}

/* Inline loading (smaller, for buttons/cells) */
.loading-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.loading-spinner-small {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--color-border, #e2e8f0);
    border-top-color: var(--color-primary, #2563eb);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-message-inline {
    font-size: 0.75rem;
    color: var(--color-text-muted, #64748b);
}

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

/* =============================================================================
   EMPTY STATE COMPONENT
   ============================================================================= */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
}

.empty-state-icon {
    width: 3rem;
    height: 3rem;
    color: var(--color-text-muted, #64748b);
    margin-bottom: 1rem;
}

.empty-state-icon svg {
    width: 100%;
    height: 100%;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text, #1e293b);
    margin-bottom: 0.5rem;
}

.empty-state-description {
    font-size: 0.875rem;
    color: var(--color-text-muted, #64748b);
    max-width: 24rem;
    margin-bottom: 1rem;
}

.empty-state-action {
    margin-top: 0.5rem;
}

/* =============================================================================
   ERROR STATE COMPONENT
   ============================================================================= */

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius, 8px);
}

.error-state-icon {
    width: 2.5rem;
    height: 2.5rem;
    color: #dc2626;
    margin-bottom: 1rem;
}

.error-state-icon svg {
    width: 100%;
    height: 100%;
}

.error-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: #991b1b;
    margin-bottom: 0.5rem;
}

.error-state-message {
    font-size: 0.875rem;
    color: #b91c1c;
    max-width: 24rem;
    margin-bottom: 1rem;
}

.error-state-action {
    margin-top: 0.5rem;
}

/* =============================================================================
   STAT CARD COMPONENT
   ============================================================================= */

.stat-card {
    background: var(--color-surface, #ffffff);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius, 8px);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    position: relative;
}

.stat-card-clickable {
    cursor: pointer;
    transition: all 0.15s ease;
}

.stat-card-clickable:hover {
    border-color: var(--color-primary, #2563eb);
    box-shadow: var(--shadow, 0 1px 3px rgba(0, 0, 0, 0.1));
}

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-text, #1e293b);
}

.stat-card-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted, #64748b);
    margin-top: 0.25rem;
}

.stat-card-detail {
    font-size: 0.75rem;
    color: var(--color-text-muted, #64748b);
    margin-top: 0.5rem;
}

/* Stat card variants */
.stat-card-primary .stat-card-value {
    color: var(--color-primary, #2563eb);
}

.stat-card-secondary .stat-card-value {
    color: var(--color-secondary, #64748b);
}

.stat-card-success .stat-card-value {
    color: var(--color-success, #22c55e);
}

.stat-card-warning .stat-card-value {
    color: var(--color-warning, #f59e0b);
}

.stat-card-danger .stat-card-value {
    color: var(--color-danger, #ef4444);
}

.stat-card-info .stat-card-value {
    color: #0ea5e9;
}

.stat-card-muted .stat-card-value {
    color: var(--color-text-muted, #64748b);
}

/* Stat card trend */
.stat-card-trend {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.stat-card-trend.trend-up {
    color: var(--color-success, #22c55e);
}

.stat-card-trend.trend-down {
    color: var(--color-danger, #ef4444);
}

.stat-card-trend.trend-neutral {
    color: var(--color-text-muted, #64748b);
}

/* Stat card grid */
.stat-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

/* =============================================================================
   ACTION CARD COMPONENT
   ============================================================================= */

.action-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--color-surface, #ffffff);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius, 8px);
    cursor: pointer;
    transition: all 0.15s ease;
}

.action-card:hover {
    border-color: var(--color-primary, #2563eb);
    box-shadow: var(--shadow, 0 1px 3px rgba(0, 0, 0, 0.1));
}

.action-card-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: var(--radius, 8px);
    color: var(--color-primary, #2563eb);
    flex-shrink: 0;
}

.action-card-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.action-card-content {
    flex: 1;
    min-width: 0;
}

.action-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text, #1e293b);
    margin: 0;
}

.action-card-description {
    font-size: 0.8125rem;
    color: var(--color-text-muted, #64748b);
    margin: 0.25rem 0 0;
}

.action-card-arrow {
    color: var(--color-text-muted, #64748b);
    font-size: 1rem;
    flex-shrink: 0;
}

/* Action card grid */
.action-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* Quick action button */
.quick-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-primary, #2563eb);
    background: transparent;
    border: 1px solid var(--color-primary, #2563eb);
    border-radius: var(--radius, 8px);
    cursor: pointer;
    transition: all 0.15s ease;
}

.quick-action-btn:hover {
    background: var(--color-primary, #2563eb);
    color: white;
}

/* =============================================================================
   GLOBAL SEARCH COMPONENT
   ============================================================================= */

.global-search-container {
    position: relative;
}

.global-search-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--color-surface, #ffffff);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius, 8px);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.875rem;
    color: var(--color-text-muted, #64748b);
}

.global-search-trigger:hover {
    border-color: var(--color-primary, #2563eb);
    background: #f8fafc;
}

.search-icon {
    font-size: 0.875rem;
}

.search-placeholder {
    flex: 1;
    text-align: left;
}

.search-shortcut {
    font-size: 0.6875rem;
    padding: 0.125rem 0.375rem;
    background: #f1f5f9;
    border-radius: 4px;
    font-weight: 500;
}

/* Search modal overlay */
.global-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    z-index: 1000;
}

.global-search-modal {
    width: 100%;
    max-width: 600px;
    background: var(--color-surface, #ffffff);
    border-radius: var(--radius, 8px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

/* Search input */
.global-search-input-container {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
    gap: 0.75rem;
}

.search-input-icon {
    font-size: 1.25rem;
    color: var(--color-text-muted, #64748b);
}

.global-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    background: transparent;
    color: var(--color-text, #1e293b);
}

.global-search-input::placeholder {
    color: var(--color-text-muted, #64748b);
}

.search-loading {
    color: var(--color-text-muted, #64748b);
    animation: pulse 1s infinite;
}

.search-clear-btn {
    background: none;
    border: none;
    color: var(--color-text-muted, #64748b);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.875rem;
}

.search-clear-btn:hover {
    color: var(--color-text, #1e293b);
}

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

/* Search results */
.global-search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-results-loading,
.search-results-hint,
.search-results-empty {
    padding: 2rem;
    text-align: center;
    color: var(--color-text-muted, #64748b);
    font-size: 0.875rem;
}

.search-results-list {
    padding: 0.5rem;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: none;
    border-radius: var(--radius, 8px);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.search-result-item:hover {
    background: #f1f5f9;
}

.result-type-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 4px;
    flex-shrink: 0;
}

.result-content {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-muted, #64748b);
    margin-top: 0.125rem;
}

.result-arrow {
    color: var(--color-text-muted, #64748b);
    flex-shrink: 0;
}

/* =============================================================================
   BULK ACTIONS COMPONENT
   ============================================================================= */

.bulk-actions-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #dbeafe;
    border-radius: var(--radius, 8px);
    margin-bottom: 1rem;
}

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

.bulk-actions-count {
    font-size: 0.875rem;
    font-weight: 500;
    color: #1e40af;
}

.bulk-actions-clear {
    font-size: 0.75rem;
    color: #3b82f6;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}

.bulk-actions-clear:hover {
    color: #1e40af;
}

.bulk-actions-buttons {
    display: flex;
    gap: 0.5rem;
}

.bulk-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius, 8px);
    cursor: pointer;
    transition: all 0.15s ease;
}

.bulk-action-primary {
    background: var(--color-primary, #2563eb);
    color: white;
}

.bulk-action-primary:hover {
    background: #1d4ed8;
}

.bulk-action-secondary {
    background: white;
    color: var(--color-text, #1e293b);
    border: 1px solid var(--color-border, #e2e8f0);
}

.bulk-action-secondary:hover {
    background: #f8fafc;
}

.bulk-action-danger {
    background: #dc2626;
    color: white;
}

.bulk-action-danger:hover {
    background: #b91c1c;
}

.bulk-action-success {
    background: #16a34a;
    color: white;
}

.bulk-action-success:hover {
    background: #15803d;
}

/* Selection checkboxes */
.bulk-select-checkbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.bulk-select-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-indicator {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--color-border, #e2e8f0);
    border-radius: 4px;
    background: white;
    position: relative;
    transition: all 0.15s ease;
}

.bulk-select-checkbox input:checked + .checkbox-indicator {
    background: var(--color-primary, #2563eb);
    border-color: var(--color-primary, #2563eb);
}

.bulk-select-checkbox input:checked + .checkbox-indicator::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.625rem;
    font-weight: bold;
}

.bulk-select-checkbox.indeterminate .checkbox-indicator {
    background: var(--color-primary, #2563eb);
    border-color: var(--color-primary, #2563eb);
}

.bulk-select-checkbox.indeterminate .checkbox-indicator::after {
    content: '−';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

/* =============================================================================
   EXPORT BUTTON COMPONENT
   ============================================================================= */

.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text, #1e293b);
    background: white;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius, 8px);
    cursor: pointer;
    transition: all 0.15s ease;
}

.export-btn:hover:not(:disabled) {
    background: #f8fafc;
    border-color: var(--color-primary, #2563eb);
}

.export-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.export-icon {
    font-size: 1rem;
}

.dropdown-arrow {
    font-size: 0.625rem;
    margin-left: 0.25rem;
}

/* Export dropdown */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    background: white;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius, 8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 140px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.15s ease;
}

.export-dropdown:hover .export-dropdown-menu,
.export-dropdown:focus-within .export-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.export-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--color-text, #1e293b);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
}

.export-dropdown-item:hover {
    background: #f1f5f9;
}

.format-icon {
    font-size: 0.875rem;
}
