/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    /* Header fixes */
    header {
        padding: 0.5rem;
        height: auto;
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: fixed;
        width: 100%;
        top: 0;
        z-index: 1000;
    }

    header .logo {
        max-width: 120px;
        height: auto;
        margin: 0 auto;
    }

    #openNav {
        font-size: 1.2rem;
        padding: 0.5rem;
        margin-right: 0;
        background: none;
        border: none;
        color: var(--text-light);
    }

    /* Main content adjustment */
    main {
        margin-top: 60px;
        padding: 1rem;
        width: 100%;
        overflow-x: hidden;
    }

    /* About section */
    #about {
        padding: 1rem;
        margin: 1rem 0;
    }

    #about p {
        font-size: 0.9rem;
        line-height: 1.5;
        padding: 1rem;
        text-align: left;
    }

    /* Services section fixes */
    #services {
        padding: 1rem;
        margin: 1rem 0;
        width: 100%;
        overflow: hidden;
    }

    .services-intro, .services-outro {
        font-size: 0.9rem;
        line-height: 1.5;
        padding: 1rem;
        margin: 1rem 0;
    }

    .services-container {
        width: 100%;
        padding: 0;
        margin: 1rem 0;
        position: relative;
    }

    #services-wrapper {
        display: flex;
        scroll-snap-type: x mandatory;
        overflow-x: hidden;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .service {
        flex: 0 0 100%;
        width: 100%;
        min-width: 100%;
        scroll-snap-align: center;
        padding: 1rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    .service img {
        width: 150px;
        height: 150px;
        border-radius: 50%;
        object-fit: cover;
        margin-bottom: 1rem;
    }

    .service h3 {
        font-size: 1rem;
        margin-top: 0.5rem;
        text-align: center;
        padding: 0 1rem;
    }

    /* Projects section fixes */
    #projects {
        padding: 1rem;
        margin: 1rem 0;
        width: 100%;
        overflow: hidden;
    }

    .projects-container {
        width: 100%;
        padding: 0;
        margin: 1rem 0;
        position: relative;
    }

    #projects-preview-wrapper {
        display: flex;
        scroll-snap-type: x mandatory;
        overflow-x: hidden;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .project-preview {
        flex: 0 0 100%;
        width: 100%;
        min-width: 100%;
        scroll-snap-align: center;
        padding: 1rem;
        box-sizing: border-box;
    }

    .preview-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
    }

    .preview-content h3 {
        font-size: 1.1rem;
        margin: 0.5rem 0;
        text-align: center;
    }

    .preview-content img {
        width: 100%;
        height: 200px;
        object-fit: cover;
        border-radius: 8px;
    }

    .more-info-btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
        margin-top: 1rem;
    }

    /* Navigation buttons styling */
    .nav-btn {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 30px;
        height: 30px;
        background: rgba(240, 84, 84, 0.8);
        border: none;
        border-radius: 50%;
        color: white;
        font-size: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 10;
        cursor: pointer;
    }

    [id^="prev-"] {
        left: 5px;
    }

    [id^="next-"] {
        right: 5px;
    }

    /* Elektro razdijelnici section */
    #elektro-razdijelnici {
        padding: 1rem;
        margin: 1rem 0;
        width: 100%;
        overflow: hidden;
    }

    .panel-container {
        width: 100%;
        padding: 0;
        margin: 1rem 0;
        position: relative;
    }

    #panels-wrapper {
        display: flex;
        scroll-snap-type: x mandatory;
        overflow-x: hidden;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .panel {
        flex: 0 0 100%;
        width: 100%;
        min-width: 100%;
        scroll-snap-align: center;
        padding: 1rem;
        box-sizing: border-box;
    }

    .panel img {
        width: 100%;
        height: 250px;
        object-fit: cover;
        border-radius: 8px;
    }

    /* Project details modal fixes */
    .project-details {
        padding-top: 50px;
    }

    .details-inner {
        padding: 1rem;
    }

    .details-inner h3 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .details-inner p, 
    .details-inner li {
        font-size: 0.9rem;
        padding: 1rem;
        margin-bottom: 0.5rem;
    }

    .project-details .gallery {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0.5rem;
    }

    .project-details .gallery img {
        height: 200px;
    }

    /* Footer adjustments */
    footer {
        padding: 2rem 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .contacts-wrapper {
        flex-direction: column;
        gap: 1rem;
    }

    .contact-person {
        padding: 1rem;
    }

    .contact-title {
        font-size: 1rem;
    }

    .contact-details p {
        font-size: 0.9rem;
    }
}

/* Small screen adjustments */
@media screen and (max-width: 380px) {
    header .logo {
        max-width: 100px;
    }

    .service img {
        width: 120px;
        height: 120px;
    }

    .preview-content img {
        height: 180px;
    }

    .panel img {
        height: 200px;
    }
}

/* Ensure smooth scrolling only on non-touch devices */
@media (hover: hover) {
    .services-container,
    .projects-container,
    .panel-container {
        scroll-behavior: smooth;
    }
}

/* Prevent horizontal overflow */
body {
    overflow-x: hidden;
    width: 100%;
}

/* Fix for iOS Safari 100vh issue */
@supports (-webkit-touch-callout: none) {
    .project-details,
    #project-details-container {
        height: -webkit-fill-available;
    }
}

/* Base container fixes */
@media screen and (max-width: 768px) {
    /* General section fixes */
    section {
        width: 90%;
        margin: 1rem auto;
        padding: 1rem;
        box-sizing: border-box;
        overflow: hidden;
    }

    /* Header adjustments */
    header {
        padding: 0.5rem;
        height: 60px;
    }

    /* Main content adjustment */
    main {
        margin-top: 60px;
        padding: 0.5rem;
        width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    /* About section fixes */
    #about {
        width: 90%;
        margin: 1rem auto;
        padding: 1rem;
        background: #292929;
    }

    #about h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    #about p {
        font-size: 0.95rem;
        line-height: 1.6;
        padding: 1rem 0.5rem;
        margin: 0;
        width: 100%;
        text-align: left;
        letter-spacing: 0.3px;
    }

    /* Services section fixes */
    #services {
        width: 90%;
        margin: 1rem auto;
        padding: 1rem;
        background: #292929;
    }

    .services-container {
        width: 100%;
        padding: 0;
        margin: 1rem 0;
    }

    .services-intro, .services-outro {
        width: 100%;
        font-size: 0.95rem;
        line-height: 1.6;
        padding: 1rem 0.5rem;
        margin: 1rem 0;
        text-align: left;
    }

    #services-wrapper {
        width: 100%;
        padding: 0;
    }

    .service {
        width: 100%;
        padding: 1rem 0.5rem;
    }

    /* Projects section fixes */
    #projects {
        width: 90%;
        margin: 1rem auto;
        padding: 1rem;
        background: #292929;
    }

    .projects-container {
        width: 100%;
        padding: 0;
        margin: 1rem 0;
    }

    #projects-preview-wrapper {
        width: 100%;
        padding: 0;
    }

    .project-preview {
        width: 100%;
        padding: 0.5rem;
    }

    .preview-content {
        width: 90%;
        margin: 0 auto;
    }

    /* Elektro razdijelnici section fixes */
    #elektro-razdijelnici {
        width: 90%;
        margin: 1rem auto;
        padding: 1rem;
        background: #292929;
    }

    .panel-container {
        width: 100%;
        padding: 0;
        margin: 1rem 0;
    }

    #panels-wrapper {
        width: 100%;
        padding: 0;
    }

    .panel {
        width: 100%;
        padding: 0.5rem;
    }

    /* Navigation buttons repositioning */
    .nav-btn {
        width: 30px;
        height: 30px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 10;
    }

    [id^="prev-"] {
        left: 0.5rem;
    }

    [id^="next-"] {
        right: 0.5rem;
    }

    /* Section headings */
    section h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
        padding: 0 0.5rem;
    }

    /* Container backgrounds and borders */
    section {
        background: #292929;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
    }

    /* Fix content overflow */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Remove unnecessary margins and padding */
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
        width: 100%;
    }

    html {
        overflow-x: hidden;
    }
}

/* Smaller screens adjustments */
@media screen and (max-width: 380px) {
    section {
        width: 95%;
        padding: 0.8rem;
    }

    #about p,
    .services-intro,
    .services-outro {
        font-size: 0.9rem;
        padding: 0.8rem 0.4rem;
    }

    .nav-btn {
        width: 25px;
        height: 25px;
    }
}

/* Fix iOS Safari 100vh issue */
@supports (-webkit-touch-callout: none) {
    section {
        width: 90%;
        margin: 1rem auto;
    }
}

@media screen and (max-width: 768px) {
    /* Common carousel container styles */
    .services-container,
    .projects-container,
    .panel-container {
        position: relative;
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        scrollbar-width: none; /* Hide scrollbar Firefox */
        -ms-overflow-style: none; /* Hide scrollbar IE/Edge */
    }

    /* Hide scrollbar for Chrome/Safari */
    .services-container::-webkit-scrollbar,
    .projects-container::-webkit-scrollbar,
    .panel-container::-webkit-scrollbar {
        display: none;
    }

    /* Common wrapper styles */
    #services-wrapper,
    #projects-preview-wrapper,
    #panels-wrapper {
        display: flex;
        width: 100%;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        gap: 1rem;
        padding: 1rem;
        margin: 0;
    }

    /* Individual items */
    .service,
    .project-preview,
    .panel {
        flex: 0 0 90%;
        width: 90%;
        scroll-snap-align: center;
        scroll-snap-stop: always;
        margin: 0 auto;
    }

    /* Hide navigation buttons on touch devices */
    @media (hover: none) and (pointer: coarse) {
        .nav-btn {
            display: none;
        }
    }

    /* Add visual feedback for scrolling */
    .service,
    .project-preview,
    .panel {
        transition: transform 0.3s ease;
    }

    /* Optional: Show scroll progress */
    .services-container::after,
    .projects-container::after,
    .panel-container::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 2px;
        background: rgba(240, 84, 84, 0.2);
    }
}

@media screen and (max-width: 768px) {
    /* Common wrapper styles */
    #services-wrapper,
    #projects-preview-wrapper,
    #panels-wrapper {
        display: flex;
        width: 100%;
        overflow-x: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 0;
        padding: 0;
        scroll-behavior: smooth;
    }

    /* Individual carousel items */
    .service,
    .project-preview,
    .panel {
        flex: 0 0 100%;
        width: 100%;
        min-width: 100%;
        scroll-snap-align: center;
        scroll-snap-stop: always;
    }

    /* Container styles */
    .services-container,
    .projects-container,
    .panel-container {
        position: relative;
        width: 100%;
        overflow: hidden;
        margin: 1rem 0;
    }

    /* Navigation buttons */
    .nav-btn {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 35px;
        height: 35px;
        background: rgba(240, 84, 84, 0.9);
        border: none;
        border-radius: 50%;
        color: white;
        font-size: 1.2rem;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 10;
        cursor: pointer;
        transition: opacity 0.3s ease;
    }

    [id^="prev-"] {
        left: 10px;
    }

    [id^="next-"] {
        right: 10px;
    }

    /* Prevent text selection during swipe */
    .service,
    .project-preview,
    .panel {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    /* Hide scrollbars but keep functionality */
    .services-container,
    .projects-container,
    .panel-container {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .services-container::-webkit-scrollbar,
    .projects-container::-webkit-scrollbar,
    .panel-container::-webkit-scrollbar {
        display: none;
    }
}

@media screen and (max-width: 768px) {
    #services-wrapper,
    #projects-preview-wrapper,
    #panels-wrapper {
        scroll-snap-type: none;
        scrollbar-width: none;
        -ms-overflow-style: none;
        overflow-x: scroll;
        display: flex;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    #services-wrapper::-webkit-scrollbar,
    #projects-preview-wrapper::-webkit-scrollbar,
    #panels-wrapper::-webkit-scrollbar {
        display: none;
    }

    .service,
    .project-preview,
    .panel {
        flex: 0 0 100%;
        width: 100%;
        scroll-snap-align: none;
        pointer-events: none;
    }

    .services-container,
    .projects-container,
    .panel-container {
        overflow: hidden;
    }
}

@media screen and (max-width: 768px) {
    #services-wrapper,
    #projects-preview-wrapper,
    #panels-wrapper {
        scroll-snap-type: x mandatory;
        overflow-x: scroll;
        display: flex;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .service,
    .project-preview,
    .panel {
        flex: 0 0 100%;
        width: 100%;
        min-width: 100%;
        scroll-snap-align: center;
    }

    .services-container,
    .projects-container,
    .panel-container {
        overflow: hidden;
        width: 100%;
    }
}

@media screen and (max-width: 768px) {
    #services-wrapper,
    #projects-preview-wrapper,
    #panels-wrapper {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        scroll-behavior: smooth;
        overflow-x: scroll;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 0;
        padding: 0;
    }
    
    .service,
    .project-preview,
    .panel {
        scroll-snap-align: center;
        user-select: none;
        -webkit-user-select: none;
        width: 100%;
        flex: 0 0 100%;
    }

    .dragging {
        scroll-snap-type: none;
        cursor: grabbing;
    }
}
#project-details-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#project-details-container.active {
    opacity: 1;
}

.project-details {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.project-details.active {
    opacity: 1;
    transform: translateY(0);
}

.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.scrolling {
    scroll-snap-type: none;
}

#project-details-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#project-details-container.active {
    opacity: 1;
}

.project-details {
    display: none;
}

.project-details.active {
    display: block;
}

body.modal-open {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

[id$="-wrapper"] {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.more-info-btn {
    pointer-events: auto;
    touch-action: manipulation;
    cursor: pointer;
    min-height: 44px;
    padding: 12px 24px;
    z-index: 100;
    position: relative;
}

@media screen and (max-width: 768px) {
    #elektro-razdijelnici {
        padding: 1rem;
    }

    .panel-container {
        width: 100%;
        padding: 0;
        margin: 1rem 0;
    }

    #panels-wrapper {
        gap: 0;
        padding: 0;
    }

    .panel {
        flex: 0 0 100%;
        width: 100%;
        height: auto;
        aspect-ratio: 4/5;
        padding: 0;
        margin: 0;
        border-radius: 8px;
        overflow: hidden;
    }

    .panel img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 8px;
    }
}

/* Additional adjustment for very small screens */
@media screen and (max-width: 380px) {
    .panel {
        aspect-ratio: 3/4;  /* Slightly taller on very small screens */
    }
}

/* Add this to your CSS (styles.css or responsive.css) */
@media screen and (max-width: 768px) {
    .lightbox-nav {
        width: 40px;
        height: 40px;
        background: rgba(240, 84, 84, 0.9);
        border: none;
        color: white;
        font-size: 20px;
        border-radius: 50%;
        position: fixed;  /* Change to fixed for better mobile positioning */
        display: flex !important; /* Always show navigation buttons */
        align-items: center;
        justify-content: center;
        z-index: 100002;
        cursor: pointer;
    }

    .lightbox-prev {
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
    }

    .lightbox-next {
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        position: fixed;
        z-index: 100002;
    }

    .lightbox-content {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 50px; /* Make room for navigation buttons */
    }

    .lightbox-image {
        max-width: 100%;
        max-height: 90vh;
        object-fit: contain;
    }

    .lightbox-container.active {
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: none; /* Prevent default touch behaviors */
    }
}

@media screen and (max-width: 768px) {
    .details-inner ul {
        margin: 1rem 0;
        padding: 0;
        list-style: none;
    }

    .details-inner li {
        position: relative;
        padding: 1rem 1rem 1rem 2.5rem;
        margin-bottom: 0.8rem;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
        border-left: 3px solid #f05454;
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .details-inner li::before {
        content: '•';
        position: absolute;
        left: 1rem;
        top: 50%;
        transform: translateY(-50%);
        color: #f05454;
        font-size: 1.5rem;
        line-height: 1;
    }
}

@media screen and (max-width: 768px) {
    header .logo {
        max-width: 150px;  /* Increased from 120px */
        height: auto;
        margin: 0 auto;
    }

    /* Adjust header height to accommodate larger logo */
    header {
        padding: 0.7rem;  /* Slightly increased padding */
    }
}

/* Keep smaller size for very small screens */
@media screen and (max-width: 380px) {
    header .logo {
        max-width: 130px;  /* Still larger than original but smaller than tablets */
    }
}