/* HTMX Animations & Transitions */

/* Fade in/out para swaps */
.htmx-swapping {
    opacity: 0;
    transition: opacity 200ms ease-out;
}

.htmx-settling {
    opacity: 1;
    transition: opacity 200ms ease-in;
}

/* Loading indicators */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Spinner animation */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-primary {
    border-color: rgba(23, 141, 170, 0.3);
    border-top-color: #178daa;
}

/* Button loading state */
button.htmx-request {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 350px;
}

.toast {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.toast-success {
    border-left-color: #10b981;
}

.toast.toast-error {
    border-left-color: #ef4444;
}

.toast.toast-warning {
    border-left-color: #f59e0b;
}

.toast.toast-info {
    border-left-color: #3b82f6;
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    margin: 0 0 4px 0;
}

.toast-message {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

.toast-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #374151;
}

/* Validation Feedback */
.validation-feedback {
    margin-top: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.validation-feedback.success {
    color: #10b981;
}

.validation-feedback.error {
    color: #ef4444;
}

.validation-feedback.loading {
    color: #6b7280;
}

.validation-icon {
    width: 16px;
    height: 16px;
}

/* Input states with HTMX */
input.validating {
    border-color: #3b82f6;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%233b82f6' viewBox='0 0 16 16'%3E%3Cpath d='M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

input.is-valid {
    border-color: #10b981;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2310b981' viewBox='0 0 16 16'%3E%3Cpath d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

input.is-invalid {
    border-color: #ef4444;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23ef4444' viewBox='0 0 16 16'%3E%3Cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z'/%3E%3Cpath d='M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 20px;
    margin-bottom: 10px;
}

.skeleton-button {
    height: 40px;
    width: 120px;
}

/* Pulse effect for updated content */
@keyframes pulse-highlight {
    0% { background-color: transparent; }
    50% { background-color: rgba(16, 185, 129, 0.1); }
    100% { background-color: transparent; }
}

.htmx-added {
    animation: pulse-highlight 1s ease-out;
}

/* Slide down for new content */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-down {
    animation: slideDown 0.3s ease-out;
}

/* Progress bar for requests */
.htmx-request-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #178daa, #1396b8);
    z-index: 10000;
    animation: progressBar 1s ease-in-out infinite;
}

@keyframes progressBar {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .toast-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        padding: 12px 16px;
    }
}

/* Alpine.js transitions */
[x-cloak] {
    display: none !important;
}

.alpine-fade-enter {
    opacity: 0;
}

.alpine-fade-enter-active {
    transition: opacity 0.3s ease;
}

.alpine-fade-enter-to {
    opacity: 1;
}

.alpine-fade-leave {
    opacity: 1;
}

.alpine-fade-leave-active {
    transition: opacity 0.3s ease;
}

.alpine-fade-leave-to {
    opacity: 0;
}


/* ============================================
   TABLE & MODAL ADDITIONS
   ============================================ */

/* Table row delete animation */
.table tbody tr.deleting {
    animation: slideOutRow 300ms ease forwards;
}

@keyframes slideOutRow {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* Modal overlay */
.htmx-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 200ms ease;
}

/* Modal container */
.htmx-modal {
    background: white;
    border-radius: 8px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideInModal 300ms ease;
}

@keyframes slideInModal {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-30px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.htmx-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.htmx-modal-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.htmx-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    transition: color 0.2s;
}

.htmx-modal-close:hover {
    color: #333;
}

.htmx-modal-body {
    padding: 24px;
}

.htmx-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: #f8f9fa;
}

/* === Contact Modal - Modern Redesign === */

.htmx-modal-header--primary {
    background: linear-gradient(135deg, #d55043 0%, #b8392d 100%);
    border-bottom: none;
    padding: 18px 24px;
    gap: 14px;
}

.htmx-modal-header--primary h4 {
    color: #fff;
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
}

.htmx-modal-header--primary small {
    color: rgba(255,255,255,0.75);
    font-size: 12px;
    display: block;
    margin-top: 2px;
}

.htmx-modal-header-icon {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.htmx-modal-header-icon .glyphicon {
    color: #fff;
    font-size: 16px;
}

.htmx-modal-header-text {
    flex: 1;
}

.htmx-modal-close--white {
    color: rgba(255,255,255,0.8) !important;
    font-size: 26px;
}

.htmx-modal-close--white:hover {
    color: #fff !important;
}

/* Form fields */
.htmx-form-field {
    margin-bottom: 20px;
}

.htmx-field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: #555;
    margin-bottom: 7px;
}

.htmx-field-icon {
    color: #d55043;
    margin-right: 6px;
    font-size: 13px;
}

.htmx-field-optional {
    font-weight: 400;
    color: #888;
    font-size: 12px;
    margin-left: 5px;
}

.htmx-field-input {
    border: 1.5px solid #ccc;
    border-radius: 8px !important;
    box-shadow: none !important;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-size: 15px;
    padding: 10px 14px;
    height: auto;
    color: #222;
}

.htmx-field-input:focus {
    border-color: #d55043 !important;
    box-shadow: 0 0 0 3px rgba(213,80,67,0.15) !important;
    outline: none;
}

.htmx-field-error {
    display: block;
    color: #c0392b;
    font-size: 13px;
    margin-top: 5px;
}

.htmx-modal--contact .htmx-modal-body {
    padding: 24px 24px 8px;
}

.htmx-modal--contact .alert-sm {
    padding: 8px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    border-radius: 6px;
}

/* === Bootstrap Modal - Peppam Theme === */

.peppam-modal-content {
    border-radius: 10px !important;
    overflow: hidden;
    border: none;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}

.peppam-modal-header {
    background: linear-gradient(135deg, #d55043 0%, #b8392d 100%) !important;
    border-bottom: none !important;
    padding: 16px 20px !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px;
}

.peppam-modal-header .peppam-modal-header-icon {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.peppam-modal-header .peppam-modal-header-icon .glyphicon {
    color: #fff;
    font-size: 15px;
}

.peppam-modal-header .peppam-modal-header-icon .fa {
    color: #fff;
    font-size: 15px;
}

.peppam-modal-header .peppam-modal-header-text {
    flex: 1;
}

.peppam-modal-header .modal-title {
    color: #fff !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    margin: 0 !important;
    line-height: 1.3 !important;
}

.peppam-modal-subtitle {
    color: rgba(255,255,255,0.95) !important;
    font-size: 13px !important;
    font-weight: 400;
    display: block;
    margin-top: 2px;
}

.peppam-modal-close {
    color: rgba(255,255,255,0.8) !important;
    text-shadow: none !important;
    opacity: 1 !important;
    font-size: 26px !important;
    line-height: 1 !important;
}

.peppam-modal-close:hover {
    color: #fff !important;
}

.peppam-modal-body {
    padding: 24px 24px 12px !important;
}

.peppam-modal-footer {
    background: #f8f9fa !important;
    border-top: 1px solid #dee2e6 !important;
    padding: 14px 20px !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 8px;
}

/* Peppam modal buttons */
.btn-peppam-primary {
    background-color: #d55043 !important;
    border-color: #c0392b !important;
    color: #fff !important;
    font-weight: 600;
    font-size: 15px;
    padding: 10px 22px;
    border-radius: 7px;
    transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
    -webkit-font-smoothing: subpixel-antialiased;
}

.btn-peppam-primary:hover,
.btn-peppam-primary:focus {
    background-color: #c0392b !important;
    border-color: #a93226 !important;
    color: #fff !important;
    opacity: 0.92 !important;
}

.btn-peppam-primary:active {
    background-color: #a93226 !important;
    color: #fff !important;
}

.btn-peppam-secondary {
    background-color: #fff;
    border: 1.5px solid #bbb;
    color: #444;
    font-weight: 500;
    font-size: 15px;
    padding: 10px 22px;
    border-radius: 7px;
    transition: background-color 0.15s, border-color 0.15s;
    -webkit-font-smoothing: subpixel-antialiased;
}

.btn-peppam-secondary:hover,
.btn-peppam-secondary:focus {
    background-color: #f2f2f2;
    border-color: #999;
    color: #222;
}

/* Subtitle in modal header */
.peppam-modal-subtitle {
    color: rgba(255,255,255,0.78);
    font-size: 12px;
    display: block;
    margin-top: 2px;
    font-weight: 400;
}

/* Generic HTMX spinner for tables */
.htmx-table-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.htmx-table-loading .spinner {
    width: 32px;
    height: 32px;
    border-width: 3px;
    margin: 0 auto 15px;
}

/* Empty state */
.htmx-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.htmx-empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

/* Toast variations */
.htmx-toast {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-left: 4px solid;
    animation: slideIn 0.3s ease-out;
    min-width: 300px;
}

.htmx-toast.success {
    border-left-color: #10b981;
}

.htmx-toast.error {
    border-left-color: #ef4444;
}

.htmx-toast .toast-icon {
    font-size: 24px;
    font-weight: bold;
}

.htmx-toast.success .toast-icon {
    color: #10b981;
}

.htmx-toast.error .toast-icon {
    color: #ef4444;
}

/* Spinner for Bootstrap compatibility */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

.spinner-border {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: -0.125em;
    border: 0.25em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
