/**
 * SwissProfs - Components CSS
 * Composants UI réutilisables: boutons, badges, alertes, modals, tables
 *
 * @package SwissProfs
 */

/* ==========================================================================
   BUTTONS - BASE
   ========================================================================== */

.sp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: 2px solid transparent;
    border-radius: 0.75rem;
    transition: all 0.15s ease;
}

.sp-btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(230, 57, 70, 0.25);
}

.sp-btn:disabled,
.sp-btn.is-loading,
.sp-btn.disabled {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}

/* ==========================================================================
   BUTTONS - VARIANTS
   ========================================================================== */

.sp-btn-primary {
    background-color: #E63946;
    border-color: #E63946;
    color: #fff;
}

.sp-btn-primary:hover {
    background-color: #C1121F;
    border-color: #C1121F;
    color: #fff;
}

.sp-btn-secondary {
    background-color: #1e40af;
    border-color: #1e40af;
    color: #fff;
}

.sp-btn-secondary:hover {
    background-color: #1e3a8a;
    border-color: #1e3a8a;
    color: #fff;
}

.sp-btn-success {
    background-color: #10B981;
    border-color: #10B981;
    color: #fff;
}

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

.sp-btn-danger {
    background-color: #DC2626;
    border-color: #DC2626;
    color: #fff;
}

.sp-btn-danger:hover {
    background-color: #B91C1C;
    border-color: #B91C1C;
}

.sp-btn-warning {
    background-color: #F59E0B;
    border-color: #F59E0B;
    color: #fff;
}

.sp-btn-warning:hover {
    background-color: #D97706;
    border-color: #D97706;
}

/* Outline Variants */
.sp-btn-outline {
    background-color: transparent;
    border-color: #E5E7EB;
    color: #374151;
}

.sp-btn-outline:hover {
    background-color: #F9FAFB;
    border-color: #D1D5DB;
}

.sp-btn-outline-primary {
    background-color: transparent;
    border-color: #E63946;
    color: #E63946;
}

.sp-btn-outline-primary:hover {
    background-color: #E63946;
    color: #fff;
}

.sp-btn-outline-secondary {
    background-color: transparent;
    border-color: #1e40af;
    color: #1e40af;
}

.sp-btn-outline-secondary:hover {
    background-color: #1e40af;
    color: #fff;
}

/* Ghost/Text */
.sp-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: #374151;
}

.sp-btn-ghost:hover {
    background: #F3F4F6;
}

.sp-btn-text {
    background: none;
    border: none;
    color: #1e40af;
    padding: 0.5rem;
    min-height: auto;
}

.sp-btn-text:hover {
    color: #1e3a8a;
    background-color: #F0F9FF;
}

.sp-btn-link {
    background: none;
    border: none;
    color: #E63946;
    padding: 0;
    min-height: auto;
    text-decoration: underline;
}

.sp-btn-link:hover {
    color: #C1121F;
}

/* ==========================================================================
   BUTTONS - SIZES
   ========================================================================== */

.sp-btn-xs {
    min-height: 32px;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 0.5rem;
}

.sp-btn-sm {
    min-height: 36px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: 0.625rem;
}

.sp-btn-lg {
    min-height: 56px;
    padding: 1rem 2rem;
    font-size: 1rem;
}

.sp-btn-xl {
    min-height: 64px;
    padding: 1.25rem 2.5rem;
    font-size: 1.125rem;
}

/* ==========================================================================
   BUTTONS - MODIFIERS
   ========================================================================== */

.sp-btn-block {
    display: flex;
    width: 100%;
}

.sp-btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    min-height: auto;
}

.sp-btn-icon.sp-btn-sm {
    width: 36px;
    height: 36px;
}

.sp-btn-icon.sp-btn-lg {
    width: 56px;
    height: 56px;
}

.sp-btn-circle {
    border-radius: 50%;
}

/* Loading state */
.sp-btn.is-loading .sp-btn-text {
    opacity: 0;
}

.sp-btn.is-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: sp-btn-spin 0.6s linear infinite;
}

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

/* Button Group */
.sp-btn-group {
    display: inline-flex;
}

.sp-btn-group .sp-btn {
    border-radius: 0;
}

.sp-btn-group .sp-btn:first-child {
    border-radius: 0.75rem 0 0 0.75rem;
}

.sp-btn-group .sp-btn:last-child {
    border-radius: 0 0.75rem 0.75rem 0;
}

.sp-btn-group .sp-btn:not(:first-child) {
    margin-left: -2px;
}

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

.sp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    vertical-align: middle;
    border-radius: 9999px;
    background-color: #F3F4F6;
    color: #4B5563;
}

.sp-badge-primary {
    background-color: #E63946;
    color: #fff;
}

.sp-badge-secondary {
    background-color: #1e40af;
    color: #fff;
}

.sp-badge-success {
    background-color: #10B981;
    color: #fff;
}

.sp-badge-warning {
    background-color: #F59E0B;
    color: #fff;
}

.sp-badge-danger {
    background-color: #DC2626;
    color: #fff;
}

.sp-badge-info {
    background-color: #3B82F6;
    color: #fff;
}

.sp-badge-light {
    background-color: #F3F4F6;
    color: #4B5563;
}

.sp-badge-dark {
    background-color: #1F2937;
    color: #fff;
}

/* Premium Badge */
.sp-badge-premium {
    background: linear-gradient(135deg, #F59E0B, #F97316);
    color: #fff;
}

/* Verified Badge */
.sp-badge-verified {
    background-color: #10B981;
    color: #fff;
}

.sp-badge-verified .dashicons {
    font-size: 0.875rem;
    width: 0.875rem;
    height: 0.875rem;
    margin-right: 0.25rem;
}

/* Outline Badges */
.sp-badge-outline {
    background: transparent;
    border: 1px solid currentColor;
}

.sp-badge-outline-primary {
    color: #E63946;
    border-color: #E63946;
}

/* Badge Sizes */
.sp-badge-sm {
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
}

.sp-badge-lg {
    padding: 0.375rem 1rem;
    font-size: 0.875rem;
}

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

.sp-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.375rem;
}

.sp-status-pending {
    background-color: #FEF3C7;
    color: #92400E;
}

.sp-status-confirmed {
    background-color: #D1FAE5;
    color: #065F46;
}

.sp-status-completed {
    background-color: #DBEAFE;
    color: #1E40AF;
}

.sp-status-cancelled {
    background-color: #FEE2E2;
    color: #991B1B;
}

.sp-status-active {
    background-color: #D1FAE5;
    color: #065F46;
}

.sp-status-inactive {
    background-color: #F3F4F6;
    color: #6B7280;
}

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

.sp-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

.sp-alert .dashicons,
.sp-alert .sp-alert-icon {
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.sp-alert-content {
    flex: 1;
}

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

.sp-alert-success {
    background-color: #D1FAE5;
    color: #065F46;
    border-left: 4px solid #10B981;
}

.sp-alert-error,
.sp-alert-danger {
    background-color: #FEE2E2;
    color: #991B1B;
    border-left: 4px solid #DC2626;
}

.sp-alert-warning {
    background-color: #FEF3C7;
    color: #92400E;
    border-left: 4px solid #F59E0B;
}

.sp-alert-info {
    background-color: #DBEAFE;
    color: #1E40AF;
    border-left: 4px solid #3B82F6;
}

.sp-alert-dismiss {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.sp-alert-dismiss:hover {
    opacity: 1;
}

/* ==========================================================================
   MODAL
   ========================================================================== */

.sp-modal {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}

.sp-modal.is-open {
    display: flex;
}

.sp-modal-backdrop,
.sp-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.sp-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 500px;
    pointer-events: none;
}

.sp-modal-lg .sp-modal-dialog { max-width: 800px; }
.sp-modal-sm .sp-modal-dialog { max-width: 350px; }
.sp-modal-xl .sp-modal-dialog { max-width: 1140px; }
.sp-modal-fullscreen .sp-modal-dialog { max-width: 100%; min-height: 100vh; margin: 0; }

.sp-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: calc(100vh - 2rem);
    pointer-events: auto;
    background-color: #fff;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.sp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #E5E7EB;
}

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

.sp-modal-close {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F3F4F6;
    border: none;
    border-radius: 0.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6B7280;
    transition: all 0.15s ease;
}

.sp-modal-close:hover {
    background: #E5E7EB;
    color: #374151;
}

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

.sp-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid #E5E7EB;
}

/* Modal Animation */
.sp-modal .sp-modal-content {
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.sp-modal.is-open .sp-modal-content {
    transform: scale(1);
    opacity: 1;
}

/* ==========================================================================
   TABLES
   ========================================================================== */

.sp-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.sp-table th,
.sp-table td {
    padding: 1rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #E5E7EB;
}

.sp-table th {
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6B7280;
    background: #F9FAFB;
}

.sp-table tbody tr {
    transition: background 0.15s ease;
}

.sp-table tbody tr:hover {
    background-color: #F9FAFB;
}

.sp-table tbody tr:last-child td {
    border-bottom: none;
}

.sp-table .text-right { text-align: right; }
.sp-table .text-center { text-align: center; }

/* Table Responsive Wrapper */
.sp-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sp-table-responsive .sp-table {
    min-width: 600px;
}

/* Table Striped */
.sp-table-striped tbody tr:nth-child(even) {
    background-color: #F9FAFB;
}

/* Table Bordered */
.sp-table-bordered th,
.sp-table-bordered td {
    border: 1px solid #E5E7EB;
}

/* Table Compact */
.sp-table-compact th,
.sp-table-compact td {
    padding: 0.5rem 0.75rem;
}

/* ==========================================================================
   PAGINATION
   ========================================================================== */

.sp-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 2rem;
}

.sp-pagination a,
.sp-pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.75rem;
    border-radius: 0.5rem;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    transition: all 0.15s ease;
}

.sp-pagination a:hover {
    background-color: #F3F4F6;
}

.sp-pagination .current {
    background-color: #E63946;
    color: #fff;
}

.sp-pagination .dots {
    color: #9CA3AF;
}

.sp-pagination .prev,
.sp-pagination .next {
    font-weight: 600;
}

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

.sp-empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.sp-empty-state .dashicons,
.sp-empty-state-icon {
    font-size: 3rem;
    width: 3rem;
    height: 3rem;
    color: #D1D5DB;
    margin-bottom: 1rem;
}

.sp-empty-state h3 {
    margin: 0 0 0.5rem;
    color: #374151;
}

.sp-empty-state p {
    color: #6B7280;
    margin-bottom: 1.5rem;
}

.sp-empty-state-sm {
    padding: 2rem 1rem;
}

.sp-empty-state-sm .dashicons {
    font-size: 2rem;
    width: 2rem;
    height: 2rem;
}

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

.sp-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    min-height: 200px;
}

.sp-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #E5E7EB;
    border-top-color: #E63946;
    border-radius: 50%;
    animation: sp-spin 1s linear infinite;
}

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

.sp-spinner-lg {
    width: 56px;
    height: 56px;
    border-width: 4px;
}

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

/* Skeleton Loading */
.sp-skeleton {
    background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
    background-size: 200% 100%;
    animation: sp-skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
}

.sp-skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.sp-skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 1rem;
}

.sp-skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

.sp-skeleton-img {
    width: 100%;
    height: 200px;
}

@keyframes sp-skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   TOGGLE / SWITCH
   ========================================================================== */

.sp-toggle {
    position: relative;
    display: inline-block;
    width: 3rem;
    height: 1.75rem;
}

.sp-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.sp-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #D1D5DB;
    transition: 0.3s;
    border-radius: 9999px;
}

.sp-toggle-slider::before {
    position: absolute;
    content: "";
    height: 1.25rem;
    width: 1.25rem;
    left: 0.25rem;
    bottom: 0.25rem;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sp-toggle input:checked + .sp-toggle-slider {
    background-color: #E63946;
}

.sp-toggle input:checked + .sp-toggle-slider::before {
    transform: translateX(1.25rem);
}

.sp-toggle input:focus + .sp-toggle-slider {
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.25);
}

.sp-toggle input:disabled + .sp-toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toggle with Label */
.sp-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sp-toggle-label {
    font-size: 0.9375rem;
    color: #374151;
}

/* ==========================================================================
   RATING INPUT
   ========================================================================== */

.sp-rating-input {
    display: flex;
    gap: 0.25rem;
}

.sp-rating-input .star {
    font-size: 1.5rem;
    color: #D1D5DB;
    cursor: pointer;
    transition: color 0.15s ease;
}

.sp-rating-input .star:hover,
.sp-rating-input .star.selected {
    color: #F59E0B;
}

/* Interactive rating with hover effect */
.sp-rating-input:hover .star {
    color: #F59E0B;
}

.sp-rating-input .star:hover ~ .star {
    color: #D1D5DB;
}

/* ==========================================================================
   PROGRESS BAR
   ========================================================================== */

.sp-progress {
    width: 100%;
    height: 0.5rem;
    background: #E5E7EB;
    border-radius: 9999px;
    overflow: hidden;
}

.sp-progress-bar {
    height: 100%;
    background: #E63946;
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.sp-progress-success .sp-progress-bar { background: #10B981; }
.sp-progress-warning .sp-progress-bar { background: #F59E0B; }
.sp-progress-info .sp-progress-bar { background: #3B82F6; }

.sp-progress-lg { height: 1rem; }
.sp-progress-sm { height: 0.25rem; }

/* Progress with Label */
.sp-progress-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sp-progress-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    min-width: 3rem;
    text-align: right;
}

/* ==========================================================================
   TABS
   ========================================================================== */

.sp-tabs {
    border-bottom: 2px solid #E5E7EB;
}

.sp-tabs-list {
    display: flex;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sp-tab-item {
    margin-bottom: -2px;
}

.sp-tab-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    font-weight: 500;
    color: #6B7280;
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
}

.sp-tab-link:hover {
    color: #374151;
}

.sp-tab-link.active {
    color: #E63946;
    border-bottom-color: #E63946;
}

.sp-tab-content {
    padding: 1.5rem 0;
}

.sp-tab-pane {
    display: none;
}

.sp-tab-pane.active {
    display: block;
}

/* Pills Style Tabs */
.sp-tabs-pills {
    border-bottom: none;
}

.sp-tabs-pills .sp-tabs-list {
    gap: 0.5rem;
}

.sp-tabs-pills .sp-tab-link {
    border-bottom: none;
    border-radius: 0.5rem;
    background: #F3F4F6;
}

.sp-tabs-pills .sp-tab-link:hover {
    background: #E5E7EB;
}

.sp-tabs-pills .sp-tab-link.active {
    background: #E63946;
    color: #fff;
}

/* ==========================================================================
   ACCORDION
   ========================================================================== */

.sp-accordion {
    border: 1px solid #E5E7EB;
    border-radius: 0.75rem;
    overflow: hidden;
}

.sp-accordion-item {
    border-bottom: 1px solid #E5E7EB;
}

.sp-accordion-item:last-child {
    border-bottom: none;
}

.sp-accordion-header {
    margin: 0;
}

.sp-accordion-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    text-align: left;
    background: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.sp-accordion-button:hover {
    background: #F9FAFB;
}

.sp-accordion-button::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 400;
    color: #9CA3AF;
    transition: transform 0.3s ease;
}

.sp-accordion-button.active::after {
    content: '−';
}

.sp-accordion-body {
    padding: 0 1.5rem 1rem;
    display: none;
}

.sp-accordion-body.show {
    display: block;
}

/* ==========================================================================
   CHIPS / TAGS
   ========================================================================== */

.sp-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: #F3F4F6;
    border-radius: 9999px;
    font-size: 0.875rem;
    color: #374151;
}

.sp-chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    background: #D1D5DB;
    border: none;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.sp-chip-remove:hover {
    background: #9CA3AF;
    color: #fff;
}

.sp-chip-primary {
    background: #FEE2E2;
    color: #991B1B;
}

.sp-chip-success {
    background: #D1FAE5;
    color: #065F46;
}

/* ==========================================================================
   DIVIDER
   ========================================================================== */

.sp-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #9CA3AF;
    font-size: 0.875rem;
}

.sp-divider::before,
.sp-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #E5E7EB;
}

.sp-divider-vertical {
    width: 1px;
    height: 100%;
    background: #E5E7EB;
}
