/*
 * O.Convertor Tools - Base Styles (Class-based Theme)
 * ---------------------------------------------------------
 */

/* 1. Global Styles (Light Theme Default) */
@import url('https://rsms.me/inter/inter.css');
:root { --action-bar-height: 100px; }
html { scroll-behavior: smooth; }

body {
  background-color: #f9fafb; /* gray-50 */
  font-family: "Inter", sans-serif;
  color: #1f2937; /* gray-800 */
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

.loader {
    border: 4px solid #f3f3f3; /* gray-100 */
    border-radius: 50%;
    border-top: 4px solid #3b82f6; /* blue-500 */
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* 2. Redesigned Card UI for File Items (Light Theme) */
.file-item {
    position: relative;
    background-color: #ffffff;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb; /* gray-200 */
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: grab;
    display: flex;
    flex-direction: column;
    aspect-ratio: 4 / 5;
}
.file-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    border-color: #d1d5db; /* gray-300 */
}
.file-item:active { cursor: grabbing; transform: translateY(-2px) scale(0.98); }
.dragging { opacity: 0.5; transform: scale(0.95); }

.preview-area {
    flex-grow: 1;
    background-color: #f3f4f6; /* gray-100 */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 0.5rem;
}
.preview-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    box-shadow: 0 0 1px rgba(0,0,0,0.2);
}

.file-info-footer {
    padding: 0.75rem;
    background-color: #ffffff;
    border-top: 1px solid #f3f4f6; /* gray-100 */
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.file-info-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}
.file-info-text { min-width: 0; }

.remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 10;
    background-color: rgba(255,255,255,0.8);
    backdrop-filter: blur(4px);
    border-radius: 9999px;
    transition: all 0.2s;
    border: 1px solid #e5e7eb; /* gray-200 */
}
.remove-btn:hover { background-color: #ef4444; color: white; transform: scale(1.1); border-color: transparent; }

/* 3. Skeleton Loader Styles (Light Theme) */
@keyframes pulse { 50% { opacity: .5; } }
.skeleton { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
.skeleton-preview { width: 100%; height: 100%; background-color: #e5e7eb; border-radius: 0.25rem; }
.skeleton-text { height: 0.75rem; background-color: #e5e7eb; border-radius: 0.25rem; }

/* 4. Action Bar Styles (Light Theme) */
#action-bar {
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    transform: translateY(100%);
    z-index: 50;
}
#action-bar.visible { transform: translateY(0); box-shadow: 0 -4px 20px rgba(0,0,0,0.1); }
.control-button { transition: all 0.2s ease-in-out; }
.control-button:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.control-button:active { transform: translateY(-1px); }

/* 5. Page Selector Modal Styles (Light Theme) */
#page-selector-modal.hidden { display: none; }
#modal-page-grid-container {
    position: relative;
    overflow-y: auto;
    flex-grow: 1;
    background-color: #f1f5f9; /* slate-100 */
}
#modal-page-grid {
    position: relative;
}
.page-thumbnail {
    position: relative;
    border: 1px solid #e2e8f0; /* slate-200 */
    border-radius: 0.375rem;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease-in-out;
    aspect-ratio: 8.5 / 11;
    background-color: #ffffff;
    user-select: none;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.05);
}
.page-thumbnail:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.page-thumbnail.selected {
    border-color: #3b82f6; /* blue-500 */
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4), 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.page-thumbnail canvas { width: 100%; height: 100%; object-fit: contain; }
.page-thumbnail .page-number { position: absolute; bottom: 4px; right: 6px; background-color: rgba(0,0,0,0.6); color: white; font-size: 10px; padding: 1px 4px; border-radius: 4px; }
.page-thumbnail .selection-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(59, 130, 246, 0.2);
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.page-thumbnail.selected .selection-overlay { opacity: 1; }

/* 6. FAQ Accordion Styles (Light Theme) */
.faq-item details {
    background-color: #ffffff;
    border: 1px solid #e5e7eb; /* gray-200 */
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease-in-out;
}
.faq-item details:hover {
    border-color: #3b82f6; /* blue-500 */
}
.faq-item summary {
    padding: 1rem 1.5rem;
    font-weight: 600;
    color: #1f2937; /* gray-800 */
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 300;
    color: #3b82f6; /* blue-500 */
    transition: transform 0.3s ease-in-out;
}
.faq-item details[open] summary::after { transform: rotate(45deg); }
.faq-item .faq-content {
    padding: 0 1.5rem 1.5rem;
    color: #4b5563; /* gray-600 */
    line-height: 1.6;
}

/*
 * Dark Theme Overrides
 * -------------------------------------------------
 */
.dark body {
  background-color: #0d1117;
  color: #c9d1d9;
}

.dark .loader {
    border-color: #1f2937; /* gray-800 */
    border-top-color: #60a5fa; /* blue-400 */
}

.dark .file-item {
    background-color: #161b22;
    border-color: #30363d;
}
.dark .file-item:hover {
    border-color: #4b5563; /* gray-600 */
}
.dark .preview-area {
    background-color: #0d1117;
}
.dark .file-info-footer {
    background-color: #161b22;
    border-top-color: #30363d;
}
.dark .remove-btn {
    background-color: rgba(22, 27, 34, 0.8);
    border-color: #30363d;
    color: #8b949e;
}
.dark .remove-btn:hover {
    color: #f87171; /* red-400 */
    background-color: #b91c1c; /* red-700 */
}

.dark .skeleton-preview,
.dark .skeleton-text {
    background-color: #30363d;
}

.dark #modal-page-grid-container {
    background-color: #0d1117;
}
.dark .page-thumbnail {
    border-color: #30363d;
    background-color: #161b22;
}
.dark .page-thumbnail.selected {
    border-color: #60a5fa; /* blue-400 */
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.4);
}
.dark .page-thumbnail .selection-overlay {
    background-color: rgba(96, 165, 250, 0.2);
}

.dark .faq-item details {
    background-color: #161b22;
    border-color: #30363d;
}
.dark .faq-item details:hover {
    border-color: #60a5fa; /* blue-400 */
}
.dark .faq-item summary {
    color: #c9d1d9;
}
.dark .faq-item summary::after {
    color: #60a5fa; /* blue-400 */
}
.dark .faq-item .faq-content {
    color: #9ca3af; /* gray-400 */
}