/* Path: T2Editor/plugin/ai/ai.css */

/* Modal Overlay & Container */
.t2-ai-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    backdrop-filter: blur(2px);
}

.t2-ai-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: t2AiSlideUp 0.3s ease-out;
}

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

/* Header */
.t2-ai-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.t2-ai-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.t2-ai-icon-gradient {
    color: #3b82f6;
    background: linear-gradient(135deg, #667eea, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Close Button */
.t2-ai-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    color: #6b7280;
    border-radius: 50%;
    transition: background 0.2s;
}

.t2-ai-close:hover {
    background: #f3f4f6;
}

/* Input Area */
.t2-ai-input-area {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.t2-ai-textarea-wrapper {
    position: relative;
}

.t2-ai-input {
    width: 100%;
    min-height: 80px;
    padding: 12px 12px 30px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.t2-ai-input:focus {
    border-color: #3b82f6;
}

.t2-ai-char-count {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 12px;
    color: #9ca3af;
    pointer-events: none;
}

.t2-ai-char-count.warning { color: #f59e0b; }
.t2-ai-char-count.error { color: #ef4444; }

/* Controls & Buttons */
.t2-ai-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 10px;
    gap: 12px;
}

.t2-ai-info-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    max-width: 280px;
}

.t2-ai-powered {
    padding: 6px 12px;
    background: none;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 9px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    width: 100%;
}

.t2-ai-powered:hover {
    background: #f9fafb;
}

.t2-ai-legal-text {
    font-size: 10px;
    color: #9ca3af;
    padding: 0 4px;
    line-height: 1.3;
}

.t2-ai-generate {
    padding: 8px 20px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    transition: background 0.2s;
}

.t2-ai-generate:hover {
    background: #2563eb;
}

@media (max-width: 640px) {
    .t2-ai-generate-text {
        display: none !important;
    }
}

/* Rate Limit Badges */
.t2-rate-limit-container {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
    opacity: 0.6;
    width: 100%;
}

.rate-limit-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 11px;
    color: #6b7280;
}

.rate-limit-badge.warning {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.rate-limit-badge .material-icons {
    font-size: 14px;
}

/* Result Area */
.t2-ai-result-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: none;
}

.t2-ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 40px 0;
}

.t2-ai-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: t2AiSpin 1s linear infinite;
}

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

.t2-ai-preview-box {
    position: relative;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px 16px 50px 16px;
    overflow-wrap: break-word;
    font-size: 14px;
    color: #374151;
}

.t2-ai-preview-content p {
    margin: 0 0 10px 0;
    line-height: 1.6;
}

/* Generated Content Styles (Preview) */
.t2-ai-code-preview {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 16px;
    margin: 10px 0;
    overflow-x: auto;
}

.t2-ai-code-lang {
    color: #9ca3af;
    font-size: 11px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.t2-ai-code-block {
    margin: 0;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.t2-ai-image-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

.t2-ai-table-preview {
    margin: 10px 0;
    overflow-x: auto;
}

.t2-ai-table-preview table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e5e7eb;
}

.t2-ai-table-preview th {
    border: 1px solid #e5e7eb;
    padding: 8px;
    background: #f9fafb;
    font-weight: 600;
    text-align: left;
}

.t2-ai-table-preview td {
    border: 1px solid #e5e7eb;
    padding: 8px;
}

/* Footer */
.t2-ai-footer {
    padding: 15px 20px;
    border-top: 1px solid #e5e7eb;
    display: none;
    justify-content: flex-end;
    align-items: center;
}

.t2-ai-insert {
    padding: 8px 20px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.t2-ai-insert:hover {
    background: #2563eb;
}

.t2-ai-regenerate-inline {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 6px 12px;
    background: white;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.t2-ai-regenerate-inline:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* Error Box */
.t2-ai-error-box {
    padding: 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
}

.t2-ai-error-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

/* Token Warning */
.t2-ai-token-warning {
    margin-top: 12px;
    padding: 10px 12px;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 6px;
    font-size: 12px;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Info Popup */
.t2-ai-info-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 10002;
    animation: t2AiSlideIn 0.3s ease-out;
}

.t2-ai-info-popup.closing {
    animation: t2AiSlideOut 0.3s ease-in forwards;
}

@keyframes t2AiSlideIn {
    from { transform: translate(-50%, -60%); opacity: 0; }
    to { transform: translate(-50%, -50%); opacity: 1; }
}

@keyframes t2AiSlideOut {
    from { transform: translate(-50%, -50%); opacity: 1; }
    to { transform: translate(-50%, -60%); opacity: 0; }
}

.t2-ai-info-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 16px;
}

.t2-ai-info-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.t2-ai-info-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.t2-ai-info-content {
    color: #374151;
    line-height: 1.6;
}

.t2-ai-info-box {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.t2-ai-info-box h4,
.t2-ai-info-box-blue h4,
.t2-ai-info-box-gray h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 6px;
}

.t2-ai-info-box ul {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    color: #6b7280;
    max-height: 200px;
    overflow-y: auto;
}

.t2-ai-info-box-blue {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
}

.t2-ai-info-box-blue h4 {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #0369a1;
}

.t2-ai-info-box-blue p {
    margin: 0;
    font-size: 11px;
    color: #0369a1;
    line-height: 1.5;
}

.t2-ai-info-box-gray {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
    opacity: 0.7;
}

.t2-ai-info-box-gray h4 {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
}

.t2-ai-info-box-gray p {
    margin: 0;
    font-size: 11px;
    color: #6b7280;
    line-height: 1.5;
}

.t2-ai-info-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

/* ==========================================================================
   Dark Mode Overrides
   ========================================================================== */
html[data-t2editor-theme="dark"] .t2-ai-modal {
    background: #1e1e1e;
    color: #e0e0e0;
}

html[data-t2editor-theme="dark"] .t2-ai-header,
html[data-t2editor-theme="dark"] .t2-ai-input-area,
html[data-t2editor-theme="dark"] .t2-ai-footer {
    border-color: #333;
}

html[data-t2editor-theme="dark"] .t2-ai-close {
    color: #9ca3af;
}

html[data-t2editor-theme="dark"] .t2-ai-close:hover {
    background: #333;
}

html[data-t2editor-theme="dark"] .t2-ai-input {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

html[data-t2editor-theme="dark"] .t2-ai-input:focus {
    border-color: #3b82f6;
}

html[data-t2editor-theme="dark"] .t2-ai-powered {
    color: #9ca3af;
    border-color: #444;
}

html[data-t2editor-theme="dark"] .t2-ai-powered:hover {
    background: #333;
}

html[data-t2editor-theme="dark"] .rate-limit-badge {
    background: #2d2d2d;
    border-color: #444;
    color: #9ca3af;
}

html[data-t2editor-theme="dark"] .rate-limit-badge.warning {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fecaca;
}

html[data-t2editor-theme="dark"] .t2-ai-preview-box {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

html[data-t2editor-theme="dark"] .t2-ai-table-preview th {
    background: #383838;
    border-color: #444;
}

html[data-t2editor-theme="dark"] .t2-ai-table-preview td,
html[data-t2editor-theme="dark"] .t2-ai-table-preview table {
    border-color: #444;
}

html[data-t2editor-theme="dark"] .t2-ai-regenerate-inline {
    background: #383838;
    color: #e0e0e0;
    border-color: #444;
}

html[data-t2editor-theme="dark"] .t2-ai-regenerate-inline:hover {
    background: #444;
    border-color: #666;
}

html[data-t2editor-theme="dark"] .t2-ai-error-box {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
}

html[data-t2editor-theme="dark"] .t2-ai-info-popup {
    background: #1e1e1e;
    color: #e0e0e0;
}

html[data-t2editor-theme="dark"] .t2-ai-info-title {
    color: #e0e0e0;
}

html[data-t2editor-theme="dark"] .t2-ai-info-content {
    color: #d1d5db;
}

html[data-t2editor-theme="dark"] .t2-ai-info-box {
    background: #2d2d2d;
    border-color: #444;
}

html[data-t2editor-theme="dark"] .t2-ai-info-box h4 {
    color: #e0e0e0;
}

html[data-t2editor-theme="dark"] .t2-ai-info-box ul {
    color: #9ca3af;
}

html[data-t2editor-theme="dark"] .t2-ai-info-box-blue {
    background: #0c4a6e;
    border-color: #075985;
}

html[data-t2editor-theme="dark"] .t2-ai-info-box-blue h4,
html[data-t2editor-theme="dark"] .t2-ai-info-box-blue p {
    color: #bae6fd;
}

html[data-t2editor-theme="dark"] .t2-ai-info-box-gray {
    background: #2d2d2d;
    border-color: #444;
}

html[data-t2editor-theme="dark"] .t2-ai-info-box-gray h4,
html[data-t2editor-theme="dark"] .t2-ai-info-box-gray p {
    color: #9ca3af;
}

html[data-t2editor-theme="dark"] .t2-ai-info-footer,
html[data-t2editor-theme="dark"] .t2-ai-info-box-gray,
html[data-t2editor-theme="dark"] .t2-ai-info-box,
html[data-t2editor-theme="dark"] .t2-ai-info-box-blue {
    border-color: #444;
}