/**
 * Shared portal styles. Theme colors come from CSS variables.
 * body.theme-dental  -> blue brand
 * body.theme-healthcare -> green brand
 */

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

html {
    scrollbar-gutter: stable both;
    overflow-y: scroll;
}

/* Dental (blue) — default theme */
:root,
body.theme-dental {
    --brand-primary: #0284c7;
    --brand-dark: #0369a1;
    --brand-light: #e0f2fe;
    --brand-border: #bae6fd;
    --brand-hover: #bae6fd;
    --brand-shadow: rgba(2, 132, 199, 0.35);
    --brand-focus-ring: rgba(2, 132, 199, 0.1);
    --brand-status-info: #0369a1;
}

/* Healthcare (green) */
body.theme-healthcare {
    --brand-primary: #059669;
    --brand-dark: #047857;
    --brand-light: #f0fdf4;
    --brand-border: #d1fae5;
    --brand-hover: #a7f3d0;
    --brand-shadow: rgba(5, 150, 105, 0.35);
    --brand-focus-ring: rgba(16, 185, 129, 0.1);
    --brand-status-info: #047857;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
    margin: 0;
    padding: 0;
    width: 100vw;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

/* Hide until portal-init applies brand copy (prevents wrong-theme / placeholder flash) */
body.portal-pending {
    visibility: hidden;
}

body.portal-ready {
    visibility: visible;
}

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

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-primary) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.login-overlay.hidden {
    display: none;
}

/* Success Screen */
.success-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-primary) 100%);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9998;
}

.success-screen.show {
    display: flex;
}

.success-box {
    background: white;
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.success-icon {
    width: 80px;
    height: 80px;
    background-color: #10b981;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 1.5rem;
    animation: checkmark 0.5s ease-in-out 0.3s;
}

@keyframes checkmark {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.success-icon::after {
    content: "✓";
    font-size: 3rem;
    color: white;
    font-weight: bold;
}

.success-box h2 {
    color: var(--brand-primary);
    margin-bottom: 0.5rem;
}

.success-box p {
    color: #64748b;
    margin-bottom: 1rem;
}

.success-box .redirect-msg {
    font-size: 0.85rem;
    color: #94a3b8;
}

.login-box {
    background: white;
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 400px;
}

.login-box h2 {
    color: var(--brand-primary);
    margin-bottom: 0.5rem;
    text-align: center;
}

.login-box p {
    color: #64748b;
    margin-bottom: 2rem;
    text-align: center;
    font-size: 0.9rem;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.login-form label {
    display: block;
    margin-bottom: 0.5rem;
    color: #475569;
    font-weight: 600;
}

.login-form input {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-focus-ring);
}

.login-btn {
    width: 100%;
    padding: 1rem;
    background-color: var(--brand-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.login-btn:hover {
    background-color: var(--brand-dark);
}

.login-btn:active {
    transform: scale(0.98);
}

.main-content {
    display: none;
}

.main-content.visible {
    display: block;
}

/* Header */
.header {
    background-color: var(--brand-primary);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: bold;
    margin: 0;
}

.nav {
    display: flex;
    gap: 2rem;
}

.nav a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
    white-space: nowrap;
}

.nav a:hover {
    color: var(--brand-hover);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-primary) 100%);
    color: white;
    padding: 4rem 0;
    text-align: center;
    margin-top: 0;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
}

/* Services Section */
.services {
    padding: 3rem 0;
    background-color: white;
}

.services h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--brand-primary);
}

.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.service-card {
    background-color: var(--brand-light);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--brand-border);
    transition: transform 0.3s, box-shadow 0.3s;
}

.service-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.service-card h3 {
    color: var(--brand-primary);
    margin-bottom: 0.5rem;
}

.service-card p {
    color: #64748b;
}

/* Customer Section */
.customer-section {
    padding: 3rem 0;
    background-color: var(--brand-light);
}

.customer-section h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--brand-primary);
}

.customer-section > .container > p {
    text-align: center;
    color: #64748b;
    margin-bottom: 2rem;
}

.form-container {
    max-width: 600px;
    margin: 0 auto;
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.customer-form {
    width: 100%;
    margin-bottom: 1.5rem;
}

.customer-form tr {
    border-bottom: 1px solid var(--brand-border);
}

.customer-form td {
    padding: 0.8rem 0.5rem;
}

.customer-form td:first-child {
    font-weight: 600;
    color: #475569;
    width: 40%;
}

.customer-form input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 1rem;
}

.customer-form input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-focus-ring);
}

.customer-form select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
}

.customer-form select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-focus-ring);
}

.profile-selector {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--brand-border);
}

.profile-selector label {
    display: block;
    font-weight: 600;
    color: var(--brand-primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.profile-selector select {
    width: 100%;
    padding: 0.7rem;
    border: 2px solid #cbd5e1;
    border-radius: 4px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.profile-selector select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-focus-ring);
}

.btn-primary {
    background-color: var(--brand-primary);
    color: white;
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.3s;
}

.btn-primary:hover {
    background-color: var(--brand-dark);
}

.btn-primary:active {
    transform: scale(0.98);
}

.chat-status {
    margin-top: 0.85rem;
    min-height: 1.4em;
    text-align: center;
    font-size: 0.9rem;
    color: #64748b;
}

.chat-status-ok {
    color: #047857;
}

.chat-status-error {
    color: #b91c1c;
}

.chat-status-info {
    color: var(--brand-status-info);
}

.sticky-chat {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.sticky-chat.is-hidden {
    display: none;
}

.sticky-chat-status {
    max-width: 220px;
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    background: #0f172a;
    color: #fff;
    font-size: 0.75rem;
    line-height: 1.3;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
    display: none;
}

.sticky-chat-status.show {
    display: block;
}

.sticky-chat-status.error {
    background: #b91c1c;
}

.sticky-chat-status.ok {
    background: #047857;
}

.sticky-chat-status.info {
    background: var(--brand-status-info);
}

.sticky-chat-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background-color: var(--brand-primary);
    color: white;
    cursor: pointer;
    box-shadow: 0 8px 20px var(--brand-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.2s;
}

.sticky-chat-btn:hover {
    background-color: var(--brand-dark);
    transform: scale(1.05);
}

.sticky-chat-btn:active {
    transform: scale(0.96);
}

.sticky-chat-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* Footer */
.footer {
    background-color: #1e293b;
    color: white;
    padding: 2rem 0;
    text-align: center;
    margin-top: 3rem;
}

.footer p {
    margin: 0.5rem 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        text-align: center;
    }

    .nav {
        margin-top: 1rem;
    }

    .nav a {
        margin: 0 1rem;
    }

    .hero h2 {
        font-size: 1.8rem;
    }

    .service-grid {
        grid-template-columns: 1fr;
    }

    .customer-form td {
        display: block;
        width: 100%;
    }

    .customer-form td:first-child {
        width: 100%;
        padding-bottom: 0.3rem;
    }
}
