/* Admin Console Styles
 * Copyright (c) 2025-2026 Cindy's World LLC and contributors
 */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 8px;
    background-color: #f5f5f5;
    max-width: 100vw;
    overflow-x: hidden;
}
.main-container {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}
body.auth-locked {
    overflow: hidden;
}
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 62, 80, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}
.auth-overlay.hidden {
    display: none;
}
.auth-card {
    background: #ffffff;
    border-radius: 8px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    text-align: center;
}
.auth-card h2 {
    margin-top: 0;
    color: #2c3e50;
}
.auth-card p {
    font-size: 14px;
    color: #4a5765;
    margin-bottom: 16px;
}
.auth-actions {
    margin: 16px 0 8px 0;
}
.auth-actions button {
    padding: 10px 18px;
    font-size: 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: #007bff;
    color: #ffffff;
}
.auth-actions button:disabled {
    background: #9bb8e4;
    cursor: not-allowed;
}
.auth-code-entry {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.auth-code-entry input {
    flex: 1;
    padding: 10px;
    font-size: 16px;
    border: 1px solid #ccd2da;
    border-radius: 4px;
    text-align: center;
    letter-spacing: 4px;
}
.auth-code-entry button {
    padding: 10px 16px;
    font-size: 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: #28a745;
    color: #ffffff;
}
.auth-code-entry button:disabled {
    background: #8dd3a4;
    cursor: not-allowed;
}
.auth-message {
    font-size: 14px;
    margin-top: 12px;
}
.auth-message.error {
    color: #c0392b;
}
.auth-message.info {
    color: #2c3e50;
}
.auth-message.hidden {
    display: none;
}
.console-no-access {
    margin: 16px;
    padding: 16px;
    background: #fff;
    border-radius: 4px;
    color: #2c3e50;
}
.console-no-access.hidden {
    display: none;
}
#main-tab-bar.hidden,
#tab-panels.hidden {
    display: none !important;
}
.header {
    background: #2c3e50;
    color: white;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.header h1 {
    margin: 0;
    font-size: 24px;
    flex: 1;
}
.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}
.header-avatar-btn {
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
}
.header-avatar-btn:hover {
    opacity: 0.9;
}
.header-avatar-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}
.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.2);
    display: block;
}
.header-avatar-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.header-name {
    font-size: 14px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Issue 797: impersonation controls to the left of avatar */
.header-impersonate-wrap {
    display: flex;
    align-items: center;
}
.header-impersonate-btn,
.header-stop-impersonate-btn {
    font-size: 13px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
}
.header-impersonate-btn:hover,
.header-stop-impersonate-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}
.header-impersonate-btn:focus,
.header-stop-impersonate-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}
.header-impersonate-dropdown-wrap {
    position: relative;
}
.header-impersonate-panel {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    min-width: 220px;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    padding: 6px 0;
    z-index: 1000;
}
.header-impersonate-panel.hidden {
    display: none !important;
}
.header-impersonate-panel button {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    color: #2c3e50;
    font-size: 14px;
    padding: 8px 14px;
    cursor: pointer;
}
.header-impersonate-panel button:hover {
    background: #e8ecf0;
}
.header-user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    min-width: 160px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    padding: 6px 0;
    z-index: 1000;
}
.header-user-dropdown.hidden {
    display: none !important;
}
.header-user-dropdown a {
    display: block;
    color: #2c3e50;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 0;
}
.header-user-dropdown a:hover {
    background: #e8ecf0;
}
.header-user-dropdown a:focus {
    background: #e8ecf0;
}
.auth-actions .button-link {
    display: inline-block;
    padding: 10px 20px;
    background: #4285f4;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    border: none;
    cursor: pointer;
}
.auth-actions .button-link:hover {
    background: #3367d6;
}
.tab-bar {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    visibility: visible !important;
    opacity: 1 !important;
}
/* Ensure subtab bars inside tab panels are always visible when panel is active */
.tab-panel.active .tab-bar {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}
/* Ensure subtab buttons are visible */
.tab-panel.active .tab-bar .tab-button {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}
.tab-button {
    border: none;
    background: #e0e6ed;
    color: #2c3e50;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease, color 0.2s ease;
}
.tab-button.active {
    background: #2c3e50;
    color: #fff;
}
.tab-button:hover {
    background: #cfd8e3;
}
.tab-panel {
    display: none;
}
.tab-panel.active {
    display: block;
}
/* Ensure subtab bars are visible when their parent tab panel is active */
.tab-panel.active .tab-bar {
    display: flex;
}
.subtab-panel {
    display: none;
}
.subtab-panel.active {
    display: block;
}

/* Agent Parameters styling */
.agent-param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}
.agent-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    gap: 16px;
}
.agent-status-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.agent-status-info {
    text-align: right;
    min-width: 150px;
}
@media (max-width: 600px) {
    .agent-status-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .agent-status-info {
        text-align: left;
        width: 100%;
        border-top: 1px solid #f0f0f0;
        padding-top: 8px;
    }
    .agent-param-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}
.agent-param-section {
    margin-bottom: 24px;
}
.agent-param-section h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 16px;
    color: #2c3e50;
}
.role-prompt-tag {
    display: flex;
    align-items: center;
    background: #f0f2f5;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 14px;
}
.role-prompt-tag button {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-weight: bold;
    padding: 0 4px;
    margin-left: 8px;
}
.agent-param-textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    resize: vertical;
    box-sizing: border-box;
}
.agent-param-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}
.agent-param-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
}
.agent-param-checkbox-label input {
    margin-right: 8px;
}
.role-prompts-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}
.placeholder-card {
    background: white;
    border-radius: 8px;
    padding: 40px;
    border: 1px dashed #c3c8d1;
    color: #6c757d;
    font-size: 16px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.controls {
    padding: 12px 0;
    margin-bottom: 16px;
}
.directory-selector {
    margin-bottom: 12px;
}
.directory-selector select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 300px;
}
.import-section {
    padding: 10px 0;
    margin-bottom: 12px;
}
.import-section input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-right: 10px;
}
.import-section button {
    padding: 8px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.import-section button:hover {
    background: #0056b3;
}
.media-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    margin-bottom: 16px;
    width: 100%;
}
@media (max-width: 600px) {
    .directory-selector select {
        min-width: 0;
        width: 100%;
    }
    .import-section input {
        width: 100%;
        margin-right: 0;
        margin-bottom: 8px;
    }
    .import-section button {
        width: 100%;
    }
    .auth-card {
        padding: 20px;
        max-width: 90%;
    }
    .header h1 {
        font-size: 20px;
    }
    .tab-button {
        padding: 6px 12px;
        font-size: 13px;
    }
}
.media-item {
    display: flex;
    flex-direction: row;
    gap: 12px;
    margin-bottom: 16px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
@media (max-width: 768px) {
    .media-item {
        flex-direction: column;
    }
    .media-preview {
        flex: none;
        max-width: 100%;
    }
}
/* Shared larger frame for Global Media Editor and Agents->Media */
.media-preview {
    flex: 0 0 65%;
    max-width: 65%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
}
.media-preview img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
}
.media-preview video {
    width: 100%;
    height: auto;
    object-fit: contain;
    cursor: pointer;
}
.media-preview audio {
    width: 100%;
    height: auto;
    min-height: 48px;
    display: block;
}
.media-info {
    flex: 1;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.media-info h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
}
.media-info p {
    margin: 5px 0;
    font-size: 14px;
    color: #666;
}
.description-edit {
    margin-top: 10px;
}
.description-edit textarea {
    width: 100%;
    min-height: 180px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    resize: vertical;
    background: #fafafa;
    box-sizing: border-box;
}
.description-edit button {
    margin-top: 8px;
    padding: 6px 12px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.description-edit button:hover {
    background: #1e7e34;
}
.error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
}
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}
.tgs-animation-container {
    background: transparent;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    overflow: hidden;
}
.tgs-animation-container svg {
    max-width: 100%;
    max-height: 100%;
}

/* Media Page Styles */
.media-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 8px 0;
}

.media-item {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.media-item-content {
    flex: 1;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

@media (max-width: 768px) {
    .media-item {
        flex-direction: column;
    }
    .media-preview {
        flex: none;
        max-width: 100%;
    }
}

.media-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.media-actions button {
    padding: 6px 12px;
    font-size: 13px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: #6c757d;
    color: white;
    transition: background 0.2s;
}

.media-actions button:hover {
    background: #5a6268;
}

.media-actions button.delete {
    background: #dc3545;
}

.media-actions button.delete:hover {
    background: #c82333;
}

.media-actions button.primary {
    background: #007bff;
}

.media-actions button.primary:hover {
    background: #0056b3;
}

.drop-zone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafafa;
    color: #666;
}

.drop-zone:hover {
    border-color: #999;
    background: #f5f5f5;
}

.drop-zone.drag-over {
    border-color: #007bff;
    background-color: #e7f3ff;
    color: #007bff;
}

.save-media-btn {
    padding: 3px 6px;
    font-size: 11px;
    background: #d4edda;
    color: #000;
    border: 1px solid #c3e6cb;
    border-radius: 3px;
    cursor: pointer;
    margin-top: 4px;
    transition: background 0.2s;
}

.save-media-btn:hover:not(:disabled) {
    background: #c3e6cb;
}

.save-media-btn:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    border-color: #dee2e6;
}

/* Tooltips: native title for short hints; .info-icon for hover + tap-to-show */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #6c757d;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    line-height: 1;
    cursor: help;
    vertical-align: middle;
}
.info-icon:hover {
    background: #5a6268;
}
.info-icon[data-tooltip] {
    position: relative;
}
.info-icon[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 8px);
    min-width: 160px;
    max-width: 320px;
    padding: 8px 10px;
    background: #2c3e50;
    color: #fff;
    font-size: 12px;
    font-weight: normal;
    line-height: 1.4;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    white-space: normal;
    word-wrap: break-word;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.15s, opacity 0.15s;
    z-index: 1000;
    pointer-events: none;
}
.info-icon[data-tooltip]:hover::after,
.info-icon[data-tooltip].tooltip-visible::after {
    visibility: visible;
    opacity: 1;
}
.info-icon[data-tooltip].tooltip-visible::after {
    pointer-events: auto;
}

.llm-delete-btn:hover {
    color: #666;
}

.llm-delete-btn:focus {
    outline: 1px dotted #999;
}

.schedule-delete-btn:hover {
    color: #666;
}

/* Schedule: on narrow viewports put activity name on its own line */
.schedule-activity-header {
    flex-wrap: wrap;
}
@media (max-width: 480px) {
    .schedule-activity-header .schedule-field-name {
        flex: 1 1 100%;
        min-width: 100%;
    }
}

/* Shared profile form layout (Agents->Profile and Conversations->Profile) */
.profile-form {
    box-sizing: border-box;
}
.profile-form input,
.profile-form select,
.profile-form textarea {
    box-sizing: border-box;
    max-width: 100%;
}
.profile-form-name-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.profile-form-photo {
    flex: 0 0 auto;
    text-align: center;
}
.profile-form-photo img,
.profile-form-photo video {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid #e0e0e0;
    object-fit: cover;
    background: #f5f5f5;
    cursor: pointer;
}
.profile-form-name-fields {
    flex: 1;
    min-width: 200px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.profile-form-fields {
    margin-top: 16px;
    display: grid;
    gap: 16px;
    min-width: 0;
}
@media (max-width: 480px) {
    .profile-form-name-fields {
        grid-template-columns: 1fr;
    }
}

