/**
 * Advanced Styles & UX Enhancements for Kresta Website
 * Includes: Toast notifications, Lightbox, Loading states, Animations,
 * Accessibility, Custom scrollbar, and more
 */

/* ============================================
   1. TOAST NOTIFICATION SYSTEM
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 300px;
    padding: 16px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(400px);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-show {
    transform: translateX(0);
}

.toast-hide {
    transform: translateX(400px);
    opacity: 0;
}

.toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background: #10b981;
    color: white;
}

.toast-error .toast-icon {
    background: #ef4444;
    color: white;
}

.toast-info .toast-icon {
    background: #3b82f6;
    color: white;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: #1a1a1a;
    line-height: 1.5;
}

.toast-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #333;
}

@media (max-width: 640px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }
}


/* ============================================
   2. LIGHTBOX/GALLERY MODAL
   ============================================ */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.lightbox-active {
    display: flex;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.3s;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    z-index: 1;
    animation: zoomIn 0.3s;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: rgba(200, 169, 98, 0.9);
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 2;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: var(--primary-gold);
    transform: scale(1.1);
}

.lightbox-close {
    top: -60px;
    right: 0;
}

.lightbox-prev {
    left: -70px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-next {
    right: -70px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-counter {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 20px;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 600;
}

@media (max-width: 768px) {
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
}


/* ============================================
   3. BACK TO TOP BUTTON
   ============================================ */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-gold), var(--secondary-gold));
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(200, 169, 98, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(100px);
    transition: all 0.3s ease;
    z-index: 1000;
}

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

.back-to-top:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 8px 30px rgba(200, 169, 98, 0.6);
}

.back-to-top svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
}


/* ============================================
   4. STICKY MOBILE CTA
   ============================================ */
.sticky-mobile-cta {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    transition: bottom 0.3s ease;
}

.sticky-mobile-cta.visible {
    bottom: 20px;
}

.sticky-cta-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--primary-gold), var(--secondary-gold));
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    font-size: 15px;
    box-shadow: 0 8px 30px rgba(200, 169, 98, 0.5);
    animation: pulse 2s infinite;
}

.sticky-cta-btn svg {
    width: 20px;
    height: 20px;
}


/* ============================================
   5. FORM VALIDATION STYLES
   ============================================ */
.form-group input.error,
.form-group textarea.error,
.form-group select.error {
    border-color: #ef4444 !important;
    animation: shake 0.3s;
}

.field-error {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
    display: block;
    animation: slideDown 0.3s;
}

.character-counter {
    text-align: right;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.form-group input.success,
.form-group textarea.success {
    border-color: #10b981 !important;
}

/* Loading spinner for form submit */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}


/* ============================================
   6. LOADING SKELETON SCREENS
   ============================================ */
.skeleton-loader {
    padding: 2rem;
}

.skeleton-item {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.skeleton-title {
    height: 40px;
    width: 60%;
}

.skeleton-text {
    height: 20px;
    width: 100%;
}

.skeleton-text:last-of-type {
    width: 80%;
}

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


/* ============================================
   7. PRELOADER
   ============================================ */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--dark-blue), var(--deep-navy));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s, visibility 0.5s;
}

.preloader-hide {
    opacity: 0;
    visibility: hidden;
}

.preloader-content {
    text-align: center;
}

.preloader-logo {
    width: 120px;
    height: auto;
    margin-bottom: 2rem;
    animation: pulse 1.5s infinite;
}

.preloader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(200, 169, 98, 0.2);
    border-top-color: var(--primary-gold);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

.preloader-text {
    color: var(--primary-gold);
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 1px;
}


/* ============================================
   8. BREADCRUMB NAVIGATION
   ============================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1.5rem;
    font-size: 14px;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.3s;
}

.breadcrumb a:hover {
    color: var(--primary-gold);
}

.breadcrumb-separator {
    color: rgba(255, 255, 255, 0.5);
}

.breadcrumb-current {
    color: var(--primary-gold);
    font-weight: 600;
}


/* ============================================
   9. ENHANCED FOCUS STATES
   ============================================ */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus,
.project-card:focus,
.accordion-title:focus {
    outline: 3px solid var(--primary-gold);
    outline-offset: 3px;
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 20px;
    background: var(--primary-gold);
    color: white;
    padding: 12px 24px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    z-index: 10000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 20px;
}


/* ============================================
   10. CUSTOM SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--light-gray);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-gold), var(--secondary-gold));
    border-radius: 6px;
    border: 2px solid var(--light-gray);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-gold);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-gold) var(--light-gray);
}


/* ============================================
   11. PROJECT COUNT BADGE
   ============================================ */
.project-count-badge {
    display: inline-block;
    margin-left: 1rem;
    padding: 0.5rem 1.25rem;
    background: linear-gradient(135deg, var(--primary-gold), var(--secondary-gold));
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 50px;
    animation: bounceIn 0.8s;
}


/* ============================================
   12. PHONE PULSE ANIMATION
   ============================================ */
.phone-pulse {
    position: relative;
    display: inline-block;
}

.phone-pulse::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: var(--primary-gold);
    opacity: 0;
    border-radius: inherit;
    animation: pulse-ring 2s infinite;
}


/* ============================================
   13. MICRO-INTERACTIONS & RIPPLE EFFECTS
   ============================================ */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}


/* ============================================
   14. ENHANCED LOADING STATES
   ============================================ */
.loading {
    pointer-events: none;
    opacity: 0.6;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}


/* ============================================
   15. IMPROVED GALLERY GRID
   ============================================ */
.gallery-item {
    cursor: zoom-in;
    transition: transform 0.3s, box-shadow 0.3s;
}

.gallery-item:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 10;
}


/* ============================================
   16. BETTER TOUCH TARGETS (Mobile)
   ============================================ */
@media (max-width: 768px) {
    .nav-link {
        padding: 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .btn {
        min-height: 48px;
        padding: 1rem 2rem;
    }

    button,
    a.btn,
    .accordion-title {
        min-height: 48px;
    }
}


/* ============================================
   17. ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@keyframes pulse-ring {
    0% {
        width: 100%;
        height: 100%;
        opacity: 0.4;
    }
    100% {
        width: 150%;
        height: 150%;
        opacity: 0;
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}


/* ============================================
   18. ACCESSIBILITY IMPROVEMENTS
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn,
    .nav-link,
    a {
        outline: 2px solid;
    }
}

/* Improved visibility for keyboard users */
:focus-visible {
    outline: 3px solid var(--primary-gold);
    outline-offset: 2px;
}


/* ============================================
   19. PRINT STYLES
   ============================================ */
@media print {
    .navbar,
    .back-to-top,
    .sticky-mobile-cta,
    .toast-container,
    .lightbox,
    .preloader {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }
}


/* ============================================
   20. RESPONSIVE ENHANCEMENTS
   ============================================ */
@media (max-width: 968px) {
    .toast-container {
        left: 10px;
        right: 10px;
    }

    .breadcrumb {
        font-size: 12px;
    }

    .project-count-badge {
        display: block;
        margin: 0.5rem auto 0;
        width: fit-content;
    }
}

@media (max-width: 640px) {
    .lightbox-counter {
        bottom: 10px;
        font-size: 12px;
    }

    .back-to-top {
        bottom: 80px;
    }
}
