/* CSS Variables */
:root {
    /* Colors */
    --primary: #1a365d;
    --secondary: #2d5a88;
    --accent: #00b4d8;
    --light: #f8f9fa;
    --dark: #1a1a1a;
    --white: #ffffff;
    --error: #dc3545;
    --success: #28a745;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background-color: var(--white);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent);
    color: var(--white);
    padding: 8px;
    z-index: 100;
    transform: translateY(0);
    transition: transform 0.3s;
}

.skip-link:focus {
    transform: translateY(40px);
}

/* Focus styles */
:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 30px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes gradientFlow {
    0% { background-position: 0% 50% }
    50% { background-position: 100% 50% }
    100% { background-position: 0% 50% }
}

.fade-in {
    opacity: 0;
    transform: translate3d(0, 30px, 0);
    will-change: transform, opacity;
}

.fade-in.visible {
    animation: fadeInUp 0.6s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

/* Hero Section */
.hero {
    position: relative;
    height: 100vh;
    background: linear-gradient(
        135deg,
        rgba(26, 54, 93, 0.15),
        rgba(45, 90, 136, 0.15)
    ), url('images/home.jpg');
    background-size: cover;
    background-position: center;
    color: var(--white);
    overflow: hidden;
    transform: translate3d(0, 0, 0);
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(26, 54, 93, 0.15) 0%,
        rgba(45, 90, 136, 0.15) 50%,
        rgba(26, 54, 93, 0.15) 100%
    );
    background-size: 200% 200%;
    animation: gradientFlow 15s ease infinite;
    will-change: background-position;
}

.hero-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    background: rgba(0, 0, 0, 0.4);
}

.hero-content {
    max-width: 800px;
    text-align: center;
    padding: 20px;
    position: relative;
    z-index: 3;
}

.logo {
    width: 180px;
    margin-bottom: 40px;
    transform: translate3d(0, 0, 0);
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    will-change: transform;
    position: relative;
    z-index: 4;
    filter: brightness(0) invert(1);
}

.logo:hover {
    transform: translate3d(0, 0, 0) scale(1.05);
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.hero p {
    font-size: clamp(1rem, 2vw, 1.25rem);
    margin-bottom: 40px;
    font-weight: 300;
    opacity: 0.9;
}

/* Sections */
section {
    padding: clamp(60px, 10vh, 100px) 0;
}

.section-heading {
    font-size: clamp(2rem, 4vw, 2.5rem);
    margin-bottom: 60px;
    text-align: center;
    color: var(--primary);
    position: relative;
}

.section-heading::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--accent);
    transition: width 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    will-change: width;
}

.section-heading:hover::after {
    width: 100px;
}

/* About Section */
.about {
    background-color: var(--light);
}

.about-content {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 40px;
    align-items: start;
}

.about-text {
    font-size: 1.1rem;
    color: var(--dark);
    opacity: 0.9;
    padding-right: 20px;
}

.about-images {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 15px;
}

.about-images img {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translate3d(0, 0, 0);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    will-change: transform, box-shadow;
}

.about-images img:hover {
    transform: translate3d(0, -4px, 0);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

@media screen and (max-width: 768px) {
    .about-content {
        grid-template-columns: 1fr;
    }
    
    .about-text {
        padding-right: 0;
    }
}

/* Offer Section */
.offer {
    background-color: var(--light);
    padding: clamp(60px, 10vh, 100px) 0;
}

.offer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

.offer-card {
    background: var(--white);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    transform: translate3d(0, 0, 0);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow: hidden;
    will-change: transform, box-shadow;
    text-align: center;
}

@media screen and (max-width: 992px) {
    .offer-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

.offer-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.offer-card:hover {
    transform: translate3d(0, -8px, 0);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.12);
    border-color: var(--accent);
}

.offer-card:hover::before {
    opacity: 0.08;
}

.offer-icon {
    font-size: 2.2rem;
    color: var(--accent);
    margin-bottom: 25px;
    transform: translate3d(0, 0, 0);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    will-change: transform;
}

.offer-card:hover .offer-icon {
    transform: scale(1.15) rotate(5deg);
}

.offer-card h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--primary);
}

.offer-card p {
    color: var(--dark);
    opacity: 0.85;
    line-height: 1.7;
    margin-top: 15px;
}

/* Carousel Optimization */
.carousel {
    position: relative;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    overflow: hidden;
    background: var(--light);
    padding: 60px 0;
    perspective: 1000px;
}

.carousel-inner {
    display: flex;
    transform: translate3d(0, 0, 0);
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    width: fit-content;
    position: relative;
    gap: 40px;
    padding: 20px 60px;
    will-change: transform;
    backface-visibility: hidden;
}

.story {
    width: clamp(300px, calc(100vw - 80px), 800px);
    padding: clamp(30px, 5vw, 50px);
    background: var(--white);
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    border-radius: 20px;
    transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
    will-change: transform, opacity;
    position: relative;
    transform: translate3d(0, 0, 0) scale(0.85);
    opacity: 0.5;
    flex-shrink: 0;
}

.story.active {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 1;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
    z-index: 1;
}

/* Form Optimization */
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    transform: translate3d(0, 0, 0);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.1);
}

/* Button Optimization */
.btn {
    display: inline-block;
    padding: 15px 35px;
    background-color: var(--accent);
    color: var(--white);
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transform: translate3d(0, 0, 0);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    will-change: transform, background-color;
}

.btn:hover {
    background-color: #0095b3;
    transform: translate3d(0, -2px, 0);
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }

    .fade-in {
        opacity: 1;
        transform: none;
    }

    .carousel-inner {
        transition: none;
    }

    .story {
        transition: none;
    }
}

/* Image Loading */
img {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .about-content,
    .contact-grid {
        grid-template-columns: 1fr;
    }

    .carousel-inner {
        padding: 20px 40px;
        gap: 20px;
    }

    .carousel-btn {
        width: 35px;
        height: 35px;
    }

    .carousel-btn.prev {
        left: 10px;
    }

    .carousel-btn.next {
        right: 10px;
    }
}

@media screen and (max-width: 480px) {
    .btn {
        width: 100%;
        margin-bottom: 15px;
    }
}

/* Chat Widget */
#chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: height 0.3s ease;
    z-index: 9999;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    height: 60px;
    display: flex;
    flex-direction: column;
}

#chat-widget.expanded {
    height: 460px;
}

#chat-body {
    display: none;
    flex: 1;
    transition: opacity 0.3s ease;
    opacity: 0;
}

#chat-widget.expanded #chat-body {
    display: flex;
    flex-direction: column;
    opacity: 1;
}

#chat-header {
    background: var(--primary);
    color: var(--white);
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.3s ease;
    height: 60px;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    z-index: 1;
}

#chat-header p {
    margin: 0;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.chat-controls {
    display: flex;
    gap: 10px;
    position: relative;
    z-index: 2;
}

.chat-controls button {
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.chat-controls button:hover {
    opacity: 1;
}

#chat-header:hover {
    background: var(--secondary);
}

#chat-header p {
    margin: 0;
    font-weight: 500;
}

#chat-header i {
    margin-right: 8px;
}

#chat-body {
    height: 400px;
    display: flex;
    flex-direction: column;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

#chat-input-container {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding: 15px;
    display: flex;
    gap: 10px;
    background: var(--light);
}

#chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s ease, height 0.2s ease;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.4;
    overflow-y: auto;
}

#chat-input:focus {
    outline: none;
    border-color: var(--accent);
}

#send-button {
    background: var(--accent);
    color: var(--white);
    border: none;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#send-button:hover {
    background: #0095b3;
    transform: translateY(-1px);
}

#send-button:active {
    transform: translateY(1px);
}

.message {
    margin-bottom: 15px;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    position: relative;
    animation: messageSlideIn 0.3s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes messageSlideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    margin-bottom: 4px;
}

.message-content.error {
    color: var(--error);
}

.message-timestamp {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.user-message {
    background: var(--light);
    margin-left: auto;
    color: var(--dark);
}

.ai-message {
    background: var(--primary);
    color: var(--white);
    margin-right: auto;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
    justify-content: flex-start;
    align-items: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--white);
    border-radius: 50%;
    animation: typing 1s infinite ease-in-out;
    opacity: 0.4;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.4s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes typing {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
        opacity: 0.8;
    }
}

@media screen and (max-width: 480px) {
    #chat-widget {
        width: 100%;
        height: 60px;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    #chat-widget.expanded {
        height: 100vh;
    }

    #chat-header {
        border-radius: 0;
    }

    #chat-messages {
        padding: 15px;
    }

    #chat-input-container {
        padding: 10px;
        padding-bottom: env(safe-area-inset-bottom, 10px);
    }

    .message {
        max-width: 90%;
        padding: 10px 14px;
    }
}

/* Additional mobile optimizations */
@media screen and (max-width: 480px) and (orientation: landscape) {
    #chat-widget.expanded {
        height: 100%;
    }
}
