/* Custom CSS overrides for Furo theme */

/* Increase main content width to 70% on desktop only */
@media (min-width: 768px) {
    .page .main .content {
        width: 70% !important;
        max-width: none !important;
    }

    /* Adjust sidebar width accordingly on desktop */
    .page .sidebar-drawer {
        width: 24em !important;
    }
}

/* Mobile optimizations */
@media (max-width: 767px) {
    /* Ensure content takes full width on mobile */
    .page .main .content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 1rem !important;
    }

    /* Reset sidebar width override for mobile - let Furo handle it */
    .page .sidebar-drawer {
        width: 15em !important;
    }

    /* Ensure mobile header is visible */
    .mobile-header {
        display: flex !important;
    }

    /* Ensure the hamburger menu is visible */
    .nav-overlay-icon {
        display: flex !important;
    }
}

/* Ensure tables use full available width */
table.docutils {
    width: 100% !important;
}

/* Make CSV tables responsive */
table.longtable {
    width: 100% !important;
    display: table !important;
}

/* Improve table readability */
table.docutils tbody tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Style stub columns (first column as header) */
table.docutils tbody th {
    background-color: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

/* ========================================
   Documentation Feedback System Styles
   ======================================== */

/* Feedback Modal */
.feedback-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.feedback-modal.active {
    display: block;
}

.feedback-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.feedback-container {
    position: relative;
    max-width: 600px;
    margin: 50px auto;
    background: var(--color-background-primary, #ffffff);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    color: var(--color-foreground-primary, #000000);
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-background-border, #e0e0e0);
}

.feedback-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-brand-primary, #4A90E2);
}

.feedback-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--color-foreground-secondary, #666);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.feedback-close:hover {
    background-color: var(--color-background-hover, #f0f0f0);
    color: var(--color-foreground-primary, #000);
}

.feedback-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.feedback-section {
    margin-bottom: 20px;
}

.feedback-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--color-foreground-primary, #000);
}

.feedback-section .required {
    color: #e74c3c;
}

.feedback-selected-text,
.feedback-url {
    padding: 12px;
    background: var(--color-background-secondary, #f8f9fa);
    border: 1px solid var(--color-background-border, #e0e0e0);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--color-foreground-primary, #000);
    word-wrap: break-word;
    max-height: 100px;
    overflow-y: auto;
}

.feedback-textarea,
.feedback-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-background-border, #d0d0d0);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--color-foreground-primary, #000);
    background: var(--color-background-primary, #ffffff);
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.feedback-textarea:focus,
.feedback-input:focus {
    outline: none;
    border-color: var(--color-brand-primary, #4A90E2);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.feedback-textarea {
    resize: vertical;
    min-height: 120px;
}

.feedback-status {
    margin-top: 12px;
    min-height: 24px;
}

.feedback-success,
.feedback-error,
.feedback-info {
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.feedback-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.feedback-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.feedback-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.feedback-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--color-background-border, #e0e0e0);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.feedback-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.feedback-btn-cancel {
    background: var(--color-background-secondary, #f0f0f0);
    color: var(--color-foreground-primary, #000);
}

.feedback-btn-cancel:hover {
    background: var(--color-background-hover, #e0e0e0);
}

.feedback-btn-submit {
    background: var(--color-brand-primary, #4A90E2);
    color: #ffffff;
}

.feedback-btn-submit:hover:not(:disabled) {
    background: #3a7bc8;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.feedback-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Feedback Hint */
.feedback-hint {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--color-brand-primary, #4A90E2);
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    font-size: 0.9rem;
    z-index: 9999;
    cursor: pointer;
    animation: slideInUp 0.4s ease-out;
    transition: opacity 0.3s;
}

.feedback-hint:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.feedback-hint.fade-out {
    opacity: 0;
}

.feedback-hint kbd {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.85em;
}

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

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .feedback-container {
        background: var(--color-background-primary, #1a1a1a);
    }

    .feedback-selected-text,
    .feedback-url {
        background: var(--color-background-secondary, #2a2a2a);
    }

    .feedback-textarea,
    .feedback-input {
        background: var(--color-background-primary, #1a1a1a);
    }
}

/* Responsive design */
@media (max-width: 640px) {
    .feedback-container {
        margin: 20px;
        max-width: calc(100% - 40px);
    }

    .feedback-hint {
        bottom: 12px;
        right: 12px;
        font-size: 0.85rem;
        padding: 10px 16px;
    }
}

/* ========================================
   Image Popover Styles
   ======================================== */

/* Popover trigger link styling */
a.popover-trigger {
    color: var(--color-brand-primary, #4A90E2);
    text-decoration: none;
    border-bottom: 1px dashed var(--color-brand-primary, #4A90E2);
    cursor: pointer;
    transition: all 0.2s ease;
}

a.popover-trigger:hover {
    color: #3a7bc8;
    border-bottom-color: #3a7bc8;
    border-bottom-style: solid;
}

/* Popover overlay */
.popover-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(3px);
    z-index: 10001;
    animation: fadeIn 0.2s ease-out;
}

.popover-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Popover container */
.popover-container {
    position: relative;
    max-width: 45vw;
    max-height: 45vh;
    background: var(--color-background-primary, #ffffff);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: popoverZoomIn 0.3s ease-out;
}

/* Popover image */
.popover-image {
    display: block;
    max-width: 100%;
    max-height: 45vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Close button */
.popover-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 32px;
    height: 32px;
    background: transparent;
    color: #000000;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
    z-index: 10002;
}

.popover-close:hover {
    opacity: 0.6;
}

/* Loading spinner */
.popover-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    min-height: 200px;
    color: var(--color-foreground-primary, #000);
}

.popover-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(74, 144, 226, 0.2);
    border-top-color: var(--color-brand-primary, #4A90E2);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Error message */
.popover-error {
    padding: 24px;
    color: #721c24;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    max-width: 400px;
    text-align: center;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes popoverZoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .popover-container {
        background: var(--color-background-primary, #1a1a1a);
    }

    .popover-error {
        background: #5a1a1a;
        color: #ffcccc;
        border-color: #8a3a3a;
    }

    .popover-loading {
        color: var(--color-foreground-primary, #ffffff);
    }
}

/* Responsive design for popovers */
@media (max-width: 640px) {
    .popover-container {
        max-width: 95vw;
        max-height: 95vh;
    }

    .popover-image {
        max-height: 90vh;
    }

    .popover-close {
        width: 36px;
        height: 36px;
        font-size: 20px;
        top: 8px;
        right: 8px;
    }
}