/**
 * NEFDHA Component Styles
 * Reusable UI components with modern design
 * Created: 2024-10-01
 */

/* ============================================================================
   CONTAINERS & LAYOUT
   ============================================================================ */

.container {
    width: 100%;
    max-width: var(--container-xl);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

@media (min-width: 640px) {
    .container {
        padding-left: var(--space-6);
        padding-right: var(--space-6);
    }
}

@media (min-width: 1024px) {
    .container {
        padding-left: var(--space-8);
        padding-right: var(--space-8);
    }
}

.container-fluid {
    width: 100%;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

/* Section spacing */
.section {
    padding-top: var(--space-16);
    padding-bottom: var(--space-16);
}

@media (max-width: 768px) {
    .section {
        padding-top: var(--space-12);
        padding-bottom: var(--space-12);
    }
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    min-height: 44px; /* WCAG 2.1 touch target minimum */
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base) var(--ease-out);
    user-select: none;
}

.btn:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

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

/* Button sizes */
.btn-sm {
    padding: var(--space-2) var(--space-4);
    min-height: 36px; /* Slightly smaller but still usable */
    font-size: var(--font-size-sm);
}

/* On touch devices, ensure small buttons still meet touch target size */
@media (pointer: coarse) {
    .btn-sm {
        min-height: 44px;
    }
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-lg);
}

.btn-xl {
    padding: var(--space-5) var(--space-10);
    font-size: var(--font-size-xl);
}

/* Button variants */
.btn-primary {
    background-color: var(--color-action-primary);
    color: var(--color-text-on-primary);
    border-color: var(--color-action-primary);
}

.btn-primary:hover {
    background-color: var(--color-action-primary-hover);
    border-color: var(--color-action-primary-hover);
    box-shadow: var(--shadow-primary);
    transform: translateY(-2px);
    color: var(--color-text-on-primary);
}

.btn-secondary {
    background-color: var(--color-action-secondary);
    color: var(--color-text-on-primary);
    border-color: var(--color-action-secondary);
}

.btn-secondary:hover {
    background-color: var(--color-action-secondary-hover);
    border-color: var(--color-action-secondary-hover);
    box-shadow: var(--shadow-secondary);
    transform: translateY(-2px);
    color: var(--color-text-on-primary);
}

.btn-accent {
    background-color: var(--color-action-accent);
    color: var(--color-text-on-primary);
    border-color: var(--color-action-accent);
}

.btn-accent:hover {
    background-color: var(--color-action-accent-hover);
    border-color: var(--color-action-accent-hover);
    box-shadow: var(--shadow-accent);
    transform: translateY(-2px);
    color: white;
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--color-action-primary);
    border-color: var(--color-action-primary);
}

.btn-outline-primary:hover {
    background-color: var(--color-action-primary);
    color: var(--color-text-on-primary);
}

.btn-outline-secondary {
    background-color: transparent;
    color: var(--color-action-secondary);
    border-color: var(--color-action-secondary);
}

.btn-outline-secondary:hover {
    background-color: var(--color-action-secondary);
    color: var(--color-text-on-primary);
}

.btn-outline-accent {
    background-color: transparent;
    color: var(--color-action-accent);
    border-color: var(--color-action-accent);
}

.btn-outline-accent:hover {
    background-color: var(--color-action-accent);
    color: var(--color-text-on-primary);
}

.btn-white {
    background-color: var(--color-surface-default);
    color: var(--color-action-primary);
    border-color: var(--color-surface-default);
}

.btn-white:hover {
    background-color: var(--color-surface-subtle);
    border-color: var(--color-surface-subtle);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.btn-dark {
    background-color: var(--color-surface-dark);
    color: var(--color-text-on-dark);
    border-color: var(--color-surface-dark);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-dark:hover {
    background-color: var(--color-gray-800);
    border-color: var(--color-gray-800);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
    color: var(--color-text-on-dark);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-body);
    border: none;
    padding: var(--space-3) var(--space-6);
    font-weight: var(--font-weight-semibold);
    transition: all var(--transition-fast) var(--ease-out);
    cursor: pointer;
    font-size: var(--font-size-body);
}

.btn-ghost:hover {
    background: var(--color-surface-muted);
}

/* Full width button */
.btn-block {
    display: flex;
    width: 100%;
}

/* ============================================================================
   CARDS
   ============================================================================ */

.card {
    background-color: var(--color-surface-default);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all var(--transition-base) var(--ease-out);
}

.card:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-4px);
}

.card-body {
    padding: var(--space-6);
}

.card-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--color-border-default);
}

.card-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--color-border-default);
    background-color: var(--color-surface-subtle);
}

.card-img-top {
    width: 100%;
    height: auto;
    display: block;
}

.card-title {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-3);
    color: var(--color-text-heading);
}

.card-text {
    color: var(--color-text-body);
    line-height: var(--line-height-relaxed);
}

/* Card with gradient overlay */
.card-gradient {
    position: relative;
    color: var(--color-white);
}

.card-gradient::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg,
        rgba(var(--color-primary-green-rgb), 0.9),
        rgba(var(--color-teal-rgb), 0.8)
    );
    z-index: 1;
}

.card-gradient > * {
    position: relative;
    z-index: 2;
}

/* ============================================================================
   BADGES
   ============================================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    color: var(--color-white);
    background-color: var(--color-gray-500);
    border-radius: var(--radius-full);
}

.badge-primary {
    background-color: var(--color-primary);
}

.badge-secondary {
    background-color: var(--color-secondary);
}

.badge-accent {
    background-color: var(--color-accent);
}

.badge-success {
    background-color: var(--color-success);
}

.badge-warning {
    background-color: var(--color-warning);
}

.badge-error {
    background-color: var(--color-error);
}

/* ============================================================================
   ALERTS
   ============================================================================ */

.alert {
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-lg);
    border-left: 4px solid;
    margin-bottom: var(--space-4);
}

.alert-success {
    background-color: var(--color-success-light);
    border-color: var(--color-success);
    color: var(--color-success-dark);
}

.alert-info {
    background-color: var(--color-info-light);
    border-color: var(--color-info);
    color: var(--color-info-dark);
}

.alert-warning {
    background-color: var(--color-warning-light);
    border-color: var(--color-warning);
    color: var(--color-warning-dark);
}

.alert-error {
    background-color: var(--color-error-light);
    border-color: var(--color-error);
    color: var(--color-error-dark);
}

/* ============================================================================
   NAVIGATION
   ============================================================================ */

.nav {
    display: flex;
    flex-wrap: wrap;
    padding-left: 0;
    margin-bottom: 0;
    list-style: none;
}

.nav-link {
    display: block;
    padding: var(--space-2) var(--space-4);
    color: var(--color-text-body);
    text-decoration: none;
    transition: all var(--transition-base) var(--ease-out);
    border-radius: var(--radius-base);
}

.nav-link:hover {
    color: var(--color-text-link-hover);
    background-color: var(--color-surface-subtle);
}

.nav-link.active {
    color: var(--color-action-primary);
    font-weight: var(--font-weight-semibold);
}

/* ============================================================================
   FORMS
   ============================================================================ */

.form-group {
    margin-bottom: var(--space-6);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-body);
}

.form-control {
    display: block;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-base);
    font-family: var(--font-body);
    line-height: var(--line-height-normal);
    color: var(--color-text-heading);
    background-color: var(--color-surface-default);
    border: 2px solid var(--color-border-default);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base) var(--ease-out);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-green-rgb), 0.1);
}

.form-control::placeholder {
    color: var(--color-text-muted);
}

.form-control:disabled {
    background-color: var(--color-surface-muted);
    cursor: not-allowed;
}

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

.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.form-check-input {
    width: 20px;
    height: 20px;
    margin-top: 0;
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
    margin-bottom: 0;
}

/* ============================================================================
   HERO SECTIONS
   ============================================================================ */

.hero {
    position: relative;
    padding-top: var(--space-24);
    padding-bottom: var(--space-24);
    overflow: hidden;
}

@media (max-width: 768px) {
    .hero {
        padding-top: var(--space-16);
        padding-bottom: var(--space-16);
    }
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero-title {
    font-size: var(--font-size-6xl);
    margin-bottom: var(--space-6);
    line-height: 1.1;
}

@media (max-width: 768px) {
    .hero-title {
        font-size: var(--font-size-4xl);
    }
}

.hero-subtitle {
    font-size: var(--font-size-xl);
    color: var(--color-text-body-subtle);
    margin-bottom: var(--space-8);
    line-height: var(--line-height-relaxed);
}

/* ============================================================================
   MODALS
   ============================================================================ */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal {
    background-color: var(--color-surface-default);
    border-radius: var(--radius-2xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    z-index: var(--z-modal);
}

.modal-header {
    padding: var(--space-6);
    background: var(--gradient-brand-background);
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

.modal-title-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.modal-icon {
    font-size: 2.5rem;
    color: var(--color-white);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.modal-icon i {
    --fa-primary-color: #ffffff;
    --fa-secondary-color: rgba(255, 255, 255, 0.7);
    --fa-secondary-opacity: 1;
}

.modal-title {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    margin: 0;
    color: var(--color-text-on-primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base) var(--ease-out);
    color: var(--color-white);
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--color-gray-200);
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

/* ============================================================================
   LOADING SPINNER
   ============================================================================ */

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

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

.spinner-sm {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

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

/* ============================================================================
   GRID SYSTEM
   ============================================================================ */

.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .grid-cols-4,
    .grid-cols-3,
    .grid-cols-2 {
        grid-template-columns: repeat(1, 1fr);
    }
}

/* ============================================================================
   DIVIDERS
   ============================================================================ */

.divider {
    height: 1px;
    background-color: var(--color-gray-200);
    margin: var(--space-8) 0;
}

.divider-vertical {
    width: 1px;
    height: 100%;
    background-color: var(--color-gray-200);
}

/* ============================================================================
   AVATAR
   ============================================================================ */

.avatar {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm {
    width: 32px;
    height: 32px;
}

.avatar-lg {
    width: 60px;
    height: 60px;
}

.avatar-xl {
    width: 80px;
    height: 80px;
}

/* ============================================================================
   BACK TO TOP BUTTON
   ============================================================================ */

.back-to-top {
    position: fixed;
    bottom: var(--space-8);
    right: var(--space-8);
    width: 50px;
    height: 50px;
    border-radius: var(--radius-full);
    background: var(--color-primary-green);
    color: var(--color-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xl);
    box-shadow: var(--shadow-primary);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--transition-base) var(--ease-out);
    z-index: var(--z-sticky);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--color-teal);
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

/* ============================================================================
   BREADCRUMB NAVIGATION
   ============================================================================ */

.breadcrumbs {
    padding: var(--space-3) 0;
    margin-bottom: var(--space-4);
}

.breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: var(--font-size-sm);
}

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.breadcrumb-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--color-text-link);
    text-decoration: none;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-base);
    transition: all var(--transition-fast) var(--ease-out);
}

.breadcrumb-link:hover {
    color: var(--color-action-primary-hover);
    background: var(--color-surface-subtle);
    text-decoration: none;
}

.breadcrumb-link:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

.breadcrumb-icon {
    font-size: 0.875rem;
    color: var(--color-action-secondary);
}

.breadcrumb-link:hover .breadcrumb-icon {
    color: var(--color-action-primary-hover);
}

.breadcrumb-separator {
    display: inline-flex;
    align-items: center;
    color: var(--color-text-muted);
    font-size: 0.625rem;
    margin: 0 var(--space-1);
    opacity: 0.6;
}

.breadcrumb-text {
    color: var(--color-text-body);
    font-weight: var(--font-weight-medium);
}

.breadcrumb-item--current .breadcrumb-text {
    color: var(--color-text-heading);
}

/* Glass morphism variant for pages with backgrounds */
.breadcrumbs--glass {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-sm);
}

/* Compact variant for constrained spaces */
.breadcrumbs--compact .breadcrumb-list {
    font-size: var(--font-size-xs);
}

.breadcrumbs--compact .breadcrumb-link {
    padding: var(--space-1);
}

.breadcrumbs--compact .breadcrumb-separator {
    margin: 0;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .breadcrumb-list {
        font-size: var(--font-size-xs);
    }

    .breadcrumb-link {
        padding: var(--space-1);
    }

    .breadcrumb-separator {
        margin: 0;
    }

    /* Truncate long breadcrumb text on mobile */
    .breadcrumb-text,
    .breadcrumb-link span {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 400px) {
    /* Even tighter truncation on very small screens */
    .breadcrumb-text,
    .breadcrumb-link span {
        max-width: 80px;
    }
}
