/**
 * TDC AI PDF Viewer Styles
 */

/* PDF Container */
.tdc-pdf-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 20px 0;
}

/* Side-by-side layout */
.tdc-pdf-container.tdc-pdf-layout-side {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto 1fr;
    min-height: 800px;
}

.tdc-pdf-layout-side .tdc-pdf-toolbar {
    grid-column: 1 / 3;
}

.tdc-pdf-layout-side .tdc-pdf-viewer {
    grid-column: 1 / 3;
    grid-row: 2;
    min-height: 700px;
}

.tdc-pdf-layout-side .tdc-pdf-ai-widget {
    grid-column: 3;
    grid-row: 1 / 3;
    margin: 0;
    height: fit-content;
    max-height: 100%;
    overflow-y: auto;
}

/* PDF Toolbar */
.tdc-pdf-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, #f8f9fa, #f0f2f5);
    padding: 12px 10px;
    margin: 15px 0;
    border-radius: 6px;
    border: 1px solid #ddd;
    border-bottom: 1px solid #ccc;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    gap: 10px;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
}

.tdc-pdf-toolbar-center {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    flex: 1;
    justify-content: flex-start;
}

/* Toolbar Button Text */
.tdc-toolbar-btn-text {
    background: white;
    border: 1px solid #ddd;
    color: #333;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.tdc-toolbar-btn-text:hover {
    background-color: #f0f0f0;
    border-color: #999;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tdc-toolbar-btn-text:active {
    background-color: #e0e0e0;
}

.tdc-toolbar-btn-text:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* PDF Title */
.tdc-pdf-title {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    height: calc(18px * 1.35 * 1);
}

/* Page Info */
.tdc-pdf-page-info {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

/* Page Input */
.tdc-pdf-page-input {
    width: 35px;
    padding: 3px 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    background: white;
}

.tdc-pdf-page-input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 3px rgba(0, 102, 204, 0.3);
}

/* Zoom Group */
.tdc-pdf-zoom-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.tdc-pdf-zoom-display {
    min-width: 35px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: #666;
}

/* Toolbar Divider */
.tdc-pdf-toolbar-divider {
    width: 1px;
    height: 16px;
    background-color: #ddd;
    margin: 0 3px;
}

/* PDF Viewer */
.tdc-pdf-viewer {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

#tdc-pdf-canvas {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    height: auto;
}

/* AI Widget Container */
.tdc-pdf-ai-widget {
    background: #f0f7ff;
    border: 1px solid #b3d9ff;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.tdc-pdf-layout-side .tdc-pdf-ai-widget {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f2ff 100%);
    border: 1px solid #a8d5ff;
    border-radius: 8px;
    padding: 20px;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tdc-pdf-ai-widget h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.tdc-pdf-layout-side .tdc-pdf-ai-widget h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #1f2937;
}

/* AI Buttons */
.tdc-pdf-ai-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.tdc-ai-btn {
    background-color: #007cba;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 150px;
}

.tdc-ai-btn:hover {
    background-color: #005a87;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

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

.tdc-ai-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Ask Question Form */
.tdc-pdf-ask-question {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#tdc-pdf-question {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#tdc-pdf-question:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 4px rgba(0, 124, 186, 0.3);
}

#tdc-pdf-ask-submit {
    background-color: #007cba;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

#tdc-pdf-ask-submit:hover {
    background-color: #005a87;
}

/* AI Result */
.tdc-pdf-ai-result {
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-left: 4px solid #007cba;
    border-radius: 4px;
    display: none;
}

.tdc-pdf-ai-response {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.tdc-pdf-ai-answer {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 15px;
    line-height: 1.7;
}

.tdc-pdf-ai-meta {
    display: block;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    color: #666;
    font-size: 12px;
}

.tdc-pdf-loading {
    color: #007cba;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.tdc-pdf-loading::after {
    content: '';
    animation: tdc-dots 1.5s steps(4, end) infinite;
}

@keyframes tdc-dots {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}

/* Desktop: Prevent toolbar wrapping */
@media (min-width: 992px) {
    .tdc-pdf-toolbar {
        flex-wrap: nowrap !important;
    }

    .tdc-pdf-toolbar-left,
    .tdc-pdf-toolbar-center,
    .tdc-pdf-toolbar-right {
        flex-wrap: nowrap !important;
    }
}

/* Mobile Responsiveness */
@media (max-width: 1200px) {
    .tdc-pdf-layout-side {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto 1fr auto !important;
        min-height: auto !important;
    }

    .tdc-pdf-layout-side .tdc-pdf-toolbar {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    .tdc-pdf-layout-side .tdc-pdf-viewer {
        grid-column: 1 !important;
        grid-row: 2 !important;
        min-height: 600px !important;
    }

    .tdc-pdf-layout-side .tdc-pdf-ai-widget {
        grid-column: 1 !important;
        grid-row: 3 !important;
        max-height: none !important;
        overflow-y: visible !important;
    }
}

@media (max-width: 768px) {
    .tdc-pdf-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .tdc-pdf-controls,
    .tdc-pdf-zoom {
        width: 100%;
        justify-content: space-between;
    }

    .tdc-pdf-ai-buttons {
        flex-direction: column;
    }

    .tdc-ai-btn {
        min-width: 100%;
        width: 100%;
    }

    .tdc-pdf-ask-question {
        flex-direction: column;
    }

    #tdc-pdf-ask-submit {
        width: 100%;
    }

    .tdc-pdf-viewer {
        height: 400px !important;
    }
}

@media (max-width: 480px) {
    .tdc-pdf-container {
        gap: 15px;
    }

    .tdc-pdf-toolbar {
        padding: 10px;
    }

    .tdc-pdf-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .tdc-pdf-page-input {
        width: 50px;
        font-size: 12px;
    }

    #tdc-pdf-zoom-level {
        font-size: 12px;
    }

    .tdc-pdf-ai-widget {
        padding: 15px;
    }

    .tdc-pdf-ai-widget h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .tdc-ai-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .tdc-pdf-ai-answer {
        font-size: 14px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .tdc-pdf-toolbar {
        background: #2a2a2a;
        border-color: #444;
    }

    .tdc-pdf-viewer {
        background: #1a1a1a;
        border-color: #444;
    }

    #tdc-pdf-canvas {
        background: #2a2a2a;
    }

    .tdc-pdf-ai-widget {
        background: #1a2a3a;
        border-color: #003d7a;
    }

    .tdc-pdf-ai-widget h3 {
        color: #e0e0e0;
    }

    .tdc-pdf-ai-result {
        background: #2a2a2a;
        border-left-color: #60a5fa;
        color: #e0e0e0;
    }

    .tdc-pdf-ai-answer {
        color: #e0e0e0;
    }

    .tdc-pdf-ai-meta {
        border-top-color: #444;
        color: #999;
    }

    #tdc-pdf-question {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }

    #tdc-pdf-question::placeholder {
        color: #999;
    }

    #tdc-pdf-zoom-level {
        color: #e0e0e0;
    }

    .tdc-pdf-page-input {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }
}

/* Print Styles */
@media print {
    .tdc-pdf-toolbar,
    .tdc-pdf-ai-widget,
    .tdc-pdf-ai-buttons {
        display: none;
    }

    .tdc-pdf-viewer {
        border: none;
        padding: 0;
        background: white;
    }
}
