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

:root {
    --primary-color: #714d98;
    --primary-dark: #5a3d7a;
    --primary-light: #8e68b8;
    --secondary-color: #9b7ec4;
    --background: #f8f7fa;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e8e3f0;
    --error: #ef4444;
    --success: #10b981;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    height: 100vh;
    position: relative;
    padding-bottom: 80px;
    margin: 0 auto;
    overflow-x: hidden;
}

/* View Management */
.view {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.view.active {
    display: block;
}

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

/* Home View */
.home-header {
    text-align: center;
    padding: clamp(1.5rem, 4vh, 2.5rem) 1.5rem clamp(1rem, 2.5vh, 1.5rem);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.app-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.greeting {
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    opacity: 0.95;
}

.quick-actions {
    padding: clamp(1.5rem, 3vh, 2rem) 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
}

.quick-actions h2 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: clamp(0.75rem, 2vw, 1rem);
    margin-top: 1.5rem;
}

.action-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: clamp(1rem, 3vw, 1.5rem) clamp(0.75rem, 2vw, 1rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    min-height: 100px;
}

.action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.action-card:active {
    transform: translateY(-2px);
}

.action-icon {
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-icon svg {
    width: clamp(22px, 5vw, 28px);
    height: clamp(22px, 5vw, 28px);
    color: var(--primary-color);
    stroke-width: 2;
}

.action-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
}

.home-footer {
    text-align: center;
    padding: 1rem 1.5rem 1.5rem;
    color: var(--text-secondary);
    position: fixed;
    bottom: 80px;
    left: 0;
    right: 0;
    background: var(--background);
}

.powered-by {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.powered-by a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.powered-by a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Messages View */
.chat-header {
    background: var(--surface);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 10;
}

.back-button, .menu-button, .icon-button {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-button:hover, .menu-button:hover, .icon-button:hover {
    background: var(--background);
}

.icon-button:active {
    transform: scale(0.95);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clear-chat-button svg {
    color: var(--text-secondary);
    transition: var(--transition);
}

.clear-chat-button:hover svg {
    color: var(--error);
}

.help-button svg {
    color: var(--text-secondary);
    transition: var(--transition);
}

.help-button:hover svg {
    color: var(--primary-color);
}

.header-info {
    flex: 1;
}

.header-info h2 {
    font-size: 1.2rem;
    margin-bottom: 0.15rem;
}

.status {
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.status.disconnected {
    color: var(--error);
}

/* Chat Messages */
.chat-messages {
    padding: 1rem clamp(0.75rem, 3vw, 1.5rem);
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    min-height: calc(100vh - 230px);
    max-height: calc(100vh - 230px);
    overflow-y: auto;
    overflow-x: hidden;
}

.message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: clamp(32px, 5vw, 40px);
    height: clamp(32px, 5vw, 40px);
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: clamp(1rem, 3vw, 1.2rem);
}

.message-avatar svg {
    width: clamp(18px, 3.5vw, 24px);
    height: clamp(18px, 3.5vw, 24px);
    color: white;
}

.user-message .message-avatar {
    background: var(--secondary-color);
}

.message-content {
    background: var(--surface);
    padding: clamp(0.75rem, 2vw, 0.875rem) clamp(0.875rem, 2.5vw, 1rem);
    border-radius: 12px;
    max-width: 75%;
    min-width: 100px;
    box-shadow: var(--shadow-sm);
    font-size: clamp(0.9rem, 2.2vw, 1rem);
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.user-message .message-content {
    background: var(--primary-color);
    color: white;
}

.message-content p {
    margin-bottom: 0.5rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul, .message-content ol {
    margin-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.message-content strong {
    font-weight: 600;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.user-message .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 1rem 1.5rem;
    max-width: 900px;
    margin: 0 auto;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-8px);
    }
}

/* Chat Input */
.chat-input-container {
    position: fixed;
    bottom: 65px;
    left: 0;
    right: 0;
    padding: clamp(0.75rem, 2vh, 1rem) clamp(0.75rem, 3vw, 1.5rem);
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 50;
}

#chat-form {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    gap: clamp(0.5rem, 2vw, 0.75rem);
}

#message-input {
    flex: 1;
    padding: clamp(0.75rem, 2vh, 0.875rem) clamp(0.875rem, 2.5vw, 1rem);
    border: 2px solid var(--border);
    border-radius: 24px;
    font-size: clamp(0.9rem, 2.2vw, 1rem);
    outline: none;
    transition: var(--transition);
    background: var(--background);
    min-height: 44px;
}

#message-input:focus {
    border-color: var(--primary-color);
    background: var(--surface);
}

#send-button {
    width: clamp(44px, 7vw, 48px);
    height: clamp(44px, 7vw, 48px);
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

#send-button:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

#send-button:active {
    transform: scale(0.95);
}

#send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Help View */
.help-header {
    background: var(--surface);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.help-header h2 {
    font-size: 1.5rem;
}

.help-content {
    padding: clamp(1rem, 3vh, 1.5rem) clamp(0.75rem, 3vw, 1.5rem);
    max-width: 900px;
    margin: 0 auto;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.help-section {
    margin-bottom: 2.5rem;
}

.help-section h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.faq-item {
    background: var(--surface);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.faq-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.faq-item h4 {
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.faq-item p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.tips-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tip-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.tip-item svg {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.tip-item span {
    flex: 1;
}

.contact-button {
    width: 100%;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 1rem;
}

.contact-button:hover {
    background: var(--primary-dark);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: clamp(0.5rem, 1.5vh, 0.75rem) 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 100;
    min-height: 65px;
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.15rem, 0.5vh, 0.25rem);
    padding: clamp(0.4rem, 1vh, 0.5rem) clamp(0.5rem, 2vw, 1rem);
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    border-radius: 8px;
    flex: 1;
    max-width: 120px;
}

.nav-item:hover {
    background: var(--background);
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item span {
    font-size: clamp(0.7rem, 1.8vw, 0.75rem);
    font-weight: 500;
}

.nav-item svg {
    width: clamp(20px, 4vw, 24px);
    height: clamp(20px, 4vw, 24px);
}

/* Responsive Design */

/* Extra Small Devices (phones, 320px to 480px) */
@media (max-width: 480px) {
    .home-header {
        padding: 2rem 1rem 1.5rem;
    }

    .quick-actions {
        padding: 1.5rem 1rem;
    }

    .action-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .action-card {
        padding: 1rem 0.75rem;
        min-height: 90px;
    }

    .action-icon svg {
        width: 20px;
        height: 20px;
    }

    .action-text {
        font-size: 0.85rem;
    }

    .message-content {
        max-width: 82%;
    }

    .chat-messages {
        padding: 1rem 0.75rem;
    }

    .message {
        gap: 0.5rem;
    }

    .faq-item {
        padding: 1rem;
    }

    .help-section h3 {
        font-size: 1.15rem;
    }
}

/* Small Devices (landscape phones, 481px to 767px) */
@media (min-width: 481px) and (max-width: 767px) {
    .action-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .message-content {
        max-width: 78%;
    }
}

/* Medium Devices (tablets, 768px to 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .app-container {
        max-width: 900px;
        margin: 0 auto;
    }

    .action-grid {
        grid-template-columns: repeat(4, 1fr);
        max-width: 800px;
        margin-left: auto;
        margin-right: auto;
    }

    .message-content {
        max-width: 70%;
    }

    .chat-messages {
        padding: 1.5rem 2rem;
    }

    .bottom-nav {
        left: 50%;
        transform: translateX(-50%);
        max-width: 900px;
    }

    .chat-input-container {
        left: 50%;
        transform: translateX(-50%);
        max-width: 900px;
    }
}

/* Large Devices (desktops, 1025px and up) */
@media (min-width: 1025px) {
    .app-container {
        max-width: 1100px;
        margin: 0 auto;
        box-shadow: var(--shadow-lg);
    }

    .action-grid {
        grid-template-columns: repeat(4, 1fr);
        max-width: 900px;
        margin-left: auto;
        margin-right: auto;
    }

    .message-content {
        max-width: 65%;
    }

    .chat-messages {
        padding: 2rem;
    }

    .bottom-nav {
        left: 50%;
        transform: translateX(-50%);
        max-width: 1100px;
        border-radius: 0;
    }

    .chat-input-container {
        left: 50%;
        transform: translateX(-50%);
        max-width: 1100px;
    }

    .home-header {
        border-radius: 0;
    }
}

/* Extra Large Devices (large desktops, 1440px and up) */
@media (min-width: 1440px) {
    .app-container {
        max-width: 1200px;
    }

    .bottom-nav {
        max-width: 1200px;
    }

    .chat-input-container {
        max-width: 1200px;
    }
}

/* Landscape Orientation for Mobile */
@media (max-height: 600px) and (orientation: landscape) {
    .home-header {
        padding: 1.5rem 1rem 1rem;
    }

    .app-title {
        font-size: 1.3rem;
    }

    .greeting {
        font-size: 0.9rem;
    }

    .quick-actions {
        padding: 1rem;
    }

    .quick-actions h2 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }

    .action-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.75rem;
    }

    .action-card {
        padding: 0.75rem 0.5rem;
        min-height: 70px;
    }

    .chat-messages {
        min-height: calc(100vh - 180px);
        max-height: calc(100vh - 180px);
        padding: 0.75rem 1rem;
    }

    .message {
        margin-bottom: 1rem;
    }

    .chat-input-container {
        padding: 0.5rem 1rem;
        bottom: 60px;
    }

    .bottom-nav {
        padding: 0.4rem 0;
        min-height: 60px;
    }

    .nav-item {
        padding: 0.3rem 0.5rem;
    }
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

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

/* Contact Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-in;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
    position: relative;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.close-modal {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-body {
    padding: 1.5rem;
}

.modal-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.required {
    color: var(--error);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--background);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--surface);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.contact-methods {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.contact-methods h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.05rem;
}

.method-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.method-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9rem;
}

.method-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.whatsapp-btn {
    color: #25D366;
    border-color: #25D366;
}

.whatsapp-btn:hover {
    background: #25D366;
    color: white;
}

.whatsapp-btn svg {
    width: 32px;
    height: 32px;
}

.email-btn {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.email-btn:hover {
    background: var(--primary-color);
    color: white;
}

.email-btn svg {
    width: 32px;
    height: 32px;
}

.call-btn {
    color: #0ea5e9;
    border-color: #0ea5e9;
}

.call-btn:hover {
    background: #0ea5e9;
    color: white;
}

.call-btn svg {
    width: 32px;
    height: 32px;
}

/* Modal Responsive */
@media (max-width: 480px) {
    .modal.active {
        padding: 0.5rem;
    }

    .modal-content {
        max-height: 95vh;
        border-radius: 12px;
    }

    .modal-header {
        padding: 1rem;
        border-radius: 12px 12px 0 0;
    }

    .modal-header h3 {
        font-size: 1.25rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .method-buttons {
        grid-template-columns: 1fr;
    }

    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

@media (min-width: 768px) {
    .method-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-150%);
    background: #1e293b;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90%;
    backdrop-filter: blur(10px);
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-icon {
    color: var(--success);
    flex-shrink: 0;
}

#toast-message {
    font-size: 0.95rem;
    font-weight: 500;
}

@media (max-width: 600px) {
    .toast-notification {
        top: 10px;
        padding: 0.875rem 1.25rem;
    }
    
    #toast-message {
        font-size: 0.9rem;
    }
}

