/* Portal Styles */

.portal-section {
    min-height: calc(100vh - 70px);
    background: var(--bg-light);
    padding: 4rem 0;
}

.portal-container {
    max-width: 500px;
    margin: 0 auto;
}

.portal-header {
    text-align: center;
    margin-bottom: 2rem;
}

.portal-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.portal-header p {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.login-form-container {
    background: var(--white);
    border-radius: 1rem;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.portal-form {
    width: 100%;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
    background: var(--bg-light);
    color: var(--text-primary);
}

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

.form-group textarea {
    resize: vertical;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.btn-full {
    width: 100%;
}

.form-footer {
    text-align: center;
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    color: var(--text-secondary);
}

.text-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.text-link:hover {
    color: var(--primary-dark);
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.75rem;
}

.auth-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    font-family: inherit;
}

.auth-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.auth-tab:hover:not(.active) {
    color: var(--text-primary);
}

/* Side-by-side first/last name fields */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.login-notice,
.register-notice {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-light);
    border-left: 4px solid var(--primary-color);
    border-radius: 0.5rem;
}

.login-notice p,
.register-notice p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dashboard-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.tenant-unit {
    color: var(--text-secondary);
    font-size: 1rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dashboard-card {
    background: var(--white);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.dashboard-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.dashboard-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    margin-top: 1.5rem;
}

.dashboard-card h3:first-child {
    margin-top: 0;
}

.full-width {
    grid-column: 1 / -1;
}

/* Quick Actions */
.quick-actions {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #ffffff;
}

.quick-actions h2 {
    color: #ffffff;
}

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

.action-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 1.25rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-icon {
    font-size: 2rem;
}

/* Info List */
.info-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.activity-item {
    display: flex;
    gap: 1rem;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.activity-icon.success {
    background: var(--success);
    color: #ffffff;
}

.activity-icon.info {
    background: var(--primary-color);
    color: #ffffff;
}

.activity-content {
    flex: 1;
}

.activity-content strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.activity-content p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.activity-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Portal Content Sections */
.portal-content-section {
    animation: fadeIn 0.3s;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.btn-back {
    background: var(--white);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

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

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Requests List */
.requests-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.request-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    transition: border-color 0.3s;
}

.request-item:hover {
    border-color: var(--primary-color);
}

.request-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.request-type {
    font-weight: 600;
    color: var(--text-primary);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-badge.completed {
    background: #064e3b;
    color: #6ee7b7;
}

.status-badge.pending {
    background: #451a03;
    color: #fcd34d;
}

.status-badge.in-progress {
    background: #1e3a5f;
    color: #93c5fd;
}

.request-description {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.request-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Documents List */
.documents-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.document-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    align-items: center;
    transition: border-color 0.3s;
}

.document-item:hover {
    border-color: var(--primary-color);
}

.document-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.document-info {
    flex: 1;
}

.document-info h4 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.document-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.document-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Messages List */
.messages-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s;
}

.message-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.message-item.unread {
    background: #162032;
    border-color: var(--primary-color);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.message-header strong {
    color: var(--text-primary);
}

.message-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.message-subject {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.message-preview {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ===========================
   AI Chatbot Widget
   =========================== */

.chatbot-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

/* Toggle Button */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    color: white;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
}

.chat-toggle-btn:active {
    transform: scale(0.97);
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 370px;
    height: 520px;
    background: var(--white);
    border-radius: 1.25rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideIn 0.3s ease;
    border: 1px solid var(--border-color);
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chat-title {
    font-weight: 600;
    font-size: 1rem;
}

.chat-status {
    font-size: 0.75rem;
    opacity: 0.85;
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

/* Message Bubbles */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.chat-message.bot-message {
    align-self: flex-start;
}

.chat-message.user-message {
    align-self: flex-end;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.bot-message .message-bubble {
    background: var(--bg-light);
    color: var(--text-primary);
    border-bottom-left-radius: 0.25rem;
}

.user-message .message-bubble {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message-time {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    padding: 0 0.25rem;
}

.user-message .message-time {
    text-align: right;
}

/* Suggestion Chips */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.suggestion-chip {
    background: var(--white);
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.35rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.suggestion-chip:hover {
    background: var(--primary-color);
    color: #ffffff;
}

/* Typing Indicator */
.typing-indicator .message-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.75rem 1rem;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Input Area */
.chat-input-area {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
    background: var(--white);
}

.chat-input {
    flex: 1;
    border: 1.5px solid var(--border-color);
    border-radius: 1.5rem;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg-light);
}

.chat-input:focus {
    border-color: var(--primary-color);
    background: var(--white);
}

.chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.08);
}

.chat-send-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
}

/* Responsive */
@media (max-width: 768px) {
    .chatbot-widget {
        bottom: 1rem;
        right: 1rem;
    }

    .chat-window {
        width: calc(100vw - 2rem);
        right: 0;
        bottom: 70px;
        height: 460px;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .portal-section {
        padding: 2rem 0;
    }

    .login-form-container {
        padding: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-header h1 {
        font-size: 1.75rem;
    }

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

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

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    .document-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .document-item .btn {
        width: 100%;
    }
}
