/* =============================================================================
   AUTH PAGES STYLES
   Login, verification, and authentication UI
   ============================================================================= */

.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 10;
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.auth-logo {
    margin-bottom: 24px;
}

.auth-logo img {
    max-width: 200px;
    height: auto;
}

.auth-title {
    font-size: 28px;
    color: #333;
    margin: 0 0 24px 0;
    font-weight: 600;
}

.auth-description {
    color: #666;
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 24px;
}

.auth-note {
    color: #888;
    font-size: 13px;
    margin-top: 16px;
}

.auth-form {
    text-align: left;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #444;
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-group input::placeholder {
    color: #aaa;
}

.auth-btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(135deg, #0066cc, #0052a3);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.auth-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.auth-btn:active {
    transform: translateY(0);
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-btn-secondary {
    width: 100%;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    color: #0066cc;
    border: 2px solid #0066cc;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    margin-top: 16px;
}

.auth-btn-secondary:hover {
    background: #0066cc;
    color: white;
}

.auth-error {
    background: #fee;
    color: #c00;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 16px;
    display: none;
}

.auth-error.visible {
    display: block;
}

.auth-success-icon {
    color: #00aa55;
    margin-bottom: 16px;
}

.auth-loading {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #eee;
    border-top-color: #0066cc;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.auth-footer {
    margin-top: 32px;
    opacity: 0.7;
}

.auth-footer img {
    max-width: 120px;
    height: auto;
}

/* Admin Page Styles */
.admin-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

.admin-header {
    background: rgba(255, 255, 255, 0.98);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-header-logo img {
    height: 40px;
}

.admin-header-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-user-info {
    font-size: 14px;
    color: #666;
}

.admin-user-info strong {
    color: #333;
}

.admin-nav {
    background: rgba(0, 0, 0, 0.95);
    padding: 0 24px;
    position: sticky;
    top: 72px; /* Height of header */
    z-index: 99;
}

.admin-nav-tabs {
    display: flex;
    gap: 4px;
}

.admin-nav-tab {
    padding: 12px 24px;
    color: #aaa;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.admin-nav-tab:hover {
    color: #fff;
}

.admin-nav-tab.active {
    color: #fff;
    border-bottom-color: #0066cc;
}

.admin-content {
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

.admin-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    scroll-margin-top: 130px; /* Account for sticky header + nav */
}

.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.admin-section-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.admin-table-wrapper {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table thead th {
    position: sticky;
    top: 0;
    background: #f8f8f8;
    z-index: 1;
}

.admin-table th,
.admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.admin-table th {
    font-weight: 600;
    color: #666;
    font-size: 13px;
    text-transform: uppercase;
}

.admin-table td {
    color: #333;
    font-size: 14px;
}

.admin-table tr:hover {
    background: #f9f9f9;
}

.role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-badge.super_admin {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.role-badge.admin {
    background: #ffe0e0;
    color: #c00;
}

.role-badge.editor {
    background: #e0f0ff;
    color: #0066cc;
}

.role-badge.viewer {
    background: #e8e8e8;
    color: #666;
}

/* Super Admin indicator in header */
.role-super-admin {
    color: #764ba2 !important;
    font-weight: 700;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.btn-small:hover {
    opacity: 0.8;
}

.btn-edit {
    background: #0066cc;
    color: white;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-primary {
    background: linear-gradient(135deg, #0066cc, #0052a3);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

/* Personas List Container */
#personasList {
    max-height: calc(100vh - 320px);
    overflow-y: auto;
    padding-right: 8px;
}

/* Persona Enhancement Card */
.persona-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: background 0.2s;
}

.persona-card:hover {
    background: #f0f0f0;
}

.persona-image {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

.persona-info {
    flex: 1;
}

.persona-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.persona-meta {
    font-size: 13px;
    color: #666;
}

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

.enhancement-badge {
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
}

.enhancement-badge.applied {
    background: #28a745;
}

.enhancement-badge.pending {
    background: #ff9800;
}

/* Content Violations Badges */
.violation-category {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
    margin-bottom: 2px;
}

.violation-category.severity-block {
    background: #fee;
    color: #c00;
}

.violation-category.severity-warn {
    background: #fff3cd;
    color: #856404;
}

.action-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.action-badge.blocked {
    background: #dc3545;
    color: white;
}

.action-badge.flagged {
    background: #ffc107;
    color: #333;
}

.action-badge.allowed {
    background: #28a745;
    color: white;
}

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.type-badge.file_upload {
    background: #e0f0ff;
    color: #0066cc;
}

.type-badge.text_input {
    background: #f0e0ff;
    color: #6600cc;
}

.type-badge.enhancement {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.2s;
}

.modal-overlay.visible .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* =============================================================================
   HELP SECTIONS - Expandable instruction panels
   ============================================================================= */

.help-section {
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fafafa;
    scroll-margin-top: 130px; /* Account for sticky header + nav */
}

.help-toggle {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #444;
    transition: background 0.2s;
    text-align: left;
}

.help-toggle:hover {
    background: linear-gradient(135deg, #e8ecf0 0%, #d8dce0 100%);
}

.help-toggle-icon {
    font-size: 10px;
    color: #666;
    transition: transform 0.2s;
}

.help-section.expanded .help-toggle-icon {
    transform: rotate(90deg);
}

.help-toggle-text {
    flex: 1;
}

.help-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.help-section.expanded .help-content {
    max-height: 1000px;
}

.help-content-inner {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.help-content-inner h4 {
    color: #333;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.help-content-inner h4:not(:first-child) {
    margin-top: 16px;
}

.help-content-inner p {
    color: #555;
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 12px 0;
}

.help-content-inner ul,
.help-content-inner ol {
    margin: 0 0 12px 0;
    padding-left: 20px;
    color: #555;
    font-size: 13px;
    line-height: 1.6;
}

.help-content-inner li {
    margin-bottom: 4px;
}

.help-content-inner li strong {
    color: #333;
}

.help-note {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    color: #92400e;
    margin-top: 12px;
}

.help-note strong {
    color: #78350f;
}

/* Help Table */
.help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 12px;
}

.help-table th,
.help-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.help-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #555;
}

.help-table td {
    color: #444;
}

.help-table tr:last-child td {
    border-bottom: none;
}

/* =============================================================================
   TOOLTIPS
   ============================================================================= */

[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    max-width: 250px;
    white-space: normal;
    text-align: center;
}

[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Tooltip positioned below */
[data-tooltip-position="bottom"]::after {
    bottom: auto;
    top: calc(100% + 8px);
}

[data-tooltip-position="bottom"]::before {
    bottom: auto;
    top: calc(100% + 2px);
    border-top-color: transparent;
    border-bottom-color: #333;
}

/* =============================================================================
   TEMPLATE EDITOR
   ============================================================================= */

/* Template Card */
.template-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: background 0.2s;
    border-left: 4px solid #059669;
}

.template-card:hover {
    background: #f0f0f0;
}

.template-card.builtin {
    border-left-color: #6366f1;
}

.template-card.disabled {
    opacity: 0.6;
    border-left-color: #9ca3af;
}

.template-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
}

.template-card.builtin .template-icon {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.template-info {
    flex: 1;
    min-width: 0;
}

.template-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.template-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.template-badge.builtin {
    background: #e0e7ff;
    color: #4338ca;
}

.template-badge.custom {
    background: #d1fae5;
    color: #065f46;
}

.template-badge.disabled {
    background: #f3f4f6;
    color: #6b7280;
}

.template-description {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

.template-stages {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.template-stage-badge {
    font-size: 11px;
    padding: 2px 8px;
    background: #e5e7eb;
    color: #374151;
    border-radius: 4px;
}

.template-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Stage Editor in Modal */
.stage-item {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.stage-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.stage-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #059669;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.stage-item-header input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.stage-remove-btn {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stage-remove-btn:hover {
    background: #fecaca;
}

.stage-description {
    margin-bottom: 10px;
}

.stage-description textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    resize: vertical;
    min-height: 40px;
}

.stage-prompts label {
    font-size: 12px;
    color: #666;
    display: block;
    margin-bottom: 6px;
}

.stage-prompts textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    resize: vertical;
    min-height: 60px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #059669;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Toggle Switch with Label */
.toggle-switch-labeled {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch-labeled .toggle-label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
    white-space: nowrap;
}

.toggle-switch-labeled input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-switch-labeled .toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
    flex-shrink: 0;
}

.toggle-switch-labeled .toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch-labeled input:checked + .toggle-slider {
    background-color: #059669;
}

.toggle-switch-labeled input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Feature Toggle Container */
.feature-toggle-container {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 8px 12px;
}

.feature-toggle-container.disabled {
    background: #fef2f2;
    border-color: #fecaca;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
    .auth-card {
        padding: 24px;
    }

    .admin-header {
        flex-direction: column;
        gap: 12px;
    }

    .admin-nav {
        top: 100px; /* Adjust for taller mobile header */
    }

    .admin-section,
    .help-section {
        scroll-margin-top: 160px; /* Adjust for taller mobile header + nav */
    }

    .admin-nav-tabs {
        overflow-x: auto;
    }

    .admin-section {
        padding: 16px;
    }

    .admin-table {
        font-size: 13px;
    }

    .admin-table th,
    .admin-table td {
        padding: 8px;
    }

    /* Help section responsive */
    .help-content-inner {
        padding: 12px 16px;
    }

    .help-table th,
    .help-table td {
        padding: 6px 8px;
        font-size: 12px;
    }

    /* Hide tooltips on mobile - too small for hover */
    [data-tooltip]::after,
    [data-tooltip]::before {
        display: none;
    }
}
