/* ============================================
   PDF TOOLS - MASTER STYLESHEET
   Fixed: Does not override Global Brand Header/Footer
   ============================================
*/

/* === 1. THEME VARIABLES === */
:root {
    /* Base Colors */
    --bg-primary: #f4f7fa; 
    --bg-secondary: #ffffff;
    --bg-secondary-hover: #f9fafb; 
    --text-primary: #1a202c; 
    --text-secondary: #4a5568;
    --text-tertiary: #718096;
    --border-color: rgba(0, 0, 0, 0.07);
    
    /* PAGE SPECIFIC COLORS (Red/Rose) - Does NOT touch global Brand vars */
    --pdf-primary: #ef4444;   /* Red 500 */
    --pdf-secondary: #f43f5e; /* Rose 500 */
    
    /* Accent for Buttons on this page */
    --accent: #ef4444;
    --accent-gradient: linear-gradient(135deg, #ef4444, #ec4899);
    
    /* Shadows & Borders */
    --shadow-color: rgba(99, 102, 241, 0.1);
    --shadow-color-darker: rgba(99, 102, 241, 0.2);
    --card-border-light: #cbd5e1;
    --card-border-dark: #334155;

    /* Button Colors */
    --btn-action-bg: #2563eb;
    --btn-action-text: #ffffff;
    --btn-action-hover: #1d4ed8;
    --btn-neutral-bg: #e5e7eb;
    --btn-neutral-text: #374151;
    --btn-neutral-hover: #d1d5db;
    --svg-arrow-color: '%236b7280';
}

body.dark {
    --bg-primary: #0f172a; 
    --bg-secondary: #1e293b; 
    --bg-secondary-hover: #28364d;
    --text-primary: #e2e8f0; 
    --text-secondary: #94a3b8; 
    --text-tertiary: #64748b;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.2);
    --shadow-color-darker: rgba(0, 0, 0, 0.3);
    
    /* Dark Mode Buttons */
    --btn-action-bg: #3b82f6;
    --btn-action-text: #ffffff;
    --btn-action-hover: #2563eb;
    --btn-neutral-bg: #334155;
    --btn-neutral-text: #e2e8f0;
    --btn-neutral-hover: #475569;
    --svg-arrow-color: '%2394a3b8';
}

/* === 2. HUB PAGE STYLES === */

/* Main Heading */
main h1 {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 2.25rem;
}
body.dark main h1 {
    color: #ffffff;
}

main > p {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

/* === 3. MODERN TOOL CARD STYLE === */
.tool-card {
    background: #ffffff; /* Explicit White for Hub Cards */
    border: 1px solid var(--card-border-light);
    border-radius: 1.25rem;
    padding: 1.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    height: 100%;
    overflow: hidden;
}

/* Remove old pseudo-element gradient border */
.tool-card::before {
    display: none; 
}

body.dark .tool-card {
    background: #1e293b; /* Slate 800 */
    border-color: var(--card-border-dark);
    box-shadow: none;
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(239, 68, 68, 0.15); /* Red Tint Shadow */
    /* Uses the local PDF Red variable now, not global brand */
    border-color: var(--pdf-primary); 
}

/* Icon Container */
.tool-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.tool-card:hover .tool-icon {
    transform: scale(1.1) rotate(3deg);
}

/* Card Typography */
.tool-card h3 {
    color: #0f172a;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: block;
}
.tool-card h3 i {
    display: none; 
}
body.dark .tool-card h3 {
    color: #f8fafc;
}

.tool-card p {
    color: #475569;
    font-size: 0.925rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
    flex-grow: 1;
}
body.dark .tool-card p {
    color: #94a3b8;
}

/* Action Text */
.action-text {
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
    margin-top: auto;
}
.tool-card:hover .action-text {
    transform: translateX(4px);
}

/* === 4. UPLOAD CARD === */
.upload-card {
    background: var(--bg-secondary);
    border: 3px dashed var(--card-border-light);
    border-radius: 1.5rem;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 25px var(--shadow-color);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px; 
}
body.dark .upload-card {
    background: var(--bg-secondary);
    border-color: var(--card-border-dark);
}
.upload-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 35px var(--shadow-color-darker);
    /* Uses local PDF Red variable */
    border-color: var(--pdf-primary); 
}
.upload-card-icon {
    font-size: 4rem;
    line-height: 1;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.1));
}
body.dark .upload-card-icon {
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.2));
}
.upload-card-title {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.upload-card-desc {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* === 5. BUTTONS & INPUTS === */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    font-size: 0.9rem;
}
.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25);
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}
.btn-primary:disabled, .btn-primary[disabled] {
    background: #fca5a5;
    color: #fee2e2;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
body.dark .btn-primary:disabled, body.dark .btn-primary[disabled] {
    background: #7f1d1d;
    color: #9ca3af;
}
.btn-success { background: #16a34a; color: white; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-secondary { background: #4b5563; color: white; }
.btn-secondary:hover:not(:disabled) { background: #374151; }

/* Modal Buttons */
.btn-action {
    background-color: var(--btn-action-bg);
    color: var(--btn-action-text);
}
.btn-action:hover {
    background-color: var(--btn-action-hover);
}
.btn-neutral {
    background-color: var(--btn-neutral-bg);
    color: var(--btn-neutral-text);
}
.btn-neutral:hover {
     background-color: var(--btn-neutral-hover);
}

/* Modal Overrides */
.modal-content-wrapper .btn-secondary,
.modal-content-wrapper .btn-neutral {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--btn-neutral-bg);
    color: var(--btn-neutral-text);
}
.modal-content-wrapper .btn-secondary:hover,
.modal-content-wrapper .btn-neutral:hover {
    background-color: var(--btn-neutral-hover);
}
.modal-content-wrapper .btn-action {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--btn-action-bg);
    color: var(--btn-action-text);
}
.modal-content-wrapper .btn-action:hover {
    background-color: var(--btn-action-hover);
}

input[type="file"].styled-input {
    border: 2px dashed var(--border-color);
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    background-color: var(--bg-primary);
    color: var(--text-tertiary);
    width: 100%;
    font-size: 0.875rem;
    transition: border-color 0.2s, background-color 0.2s;
}
input[type="file"].styled-input:hover {
    border-color: var(--pdf-primary); /* Use PDF color */
}
input[type="file"].styled-input::file-selector-button {
    margin-right: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--accent);
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}
input[type="file"].styled-input::file-selector-button:hover {
    opacity: 0.85;
}
.status-text {
    color: var(--text-tertiary);
    transition: color 0.2s;
}

/* === 6. MODAL STYLES === */
#organizeModal, #jpgModal, #compressModal, #ocrModal, #mergeModal, #imageToPdfModal { 
    backdrop-filter: blur(20px) saturate(180%);
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: radial-gradient(circle at top right, rgba(239, 68, 68, 0.05), transparent 70%),
                radial-gradient(circle at bottom left, rgba(236, 72, 153, 0.05), transparent 70%);
}
@keyframes fadeIn {
    from { opacity: 0; backdrop-filter: blur(0px); }
    to { opacity: 1; backdrop-filter: blur(20px) saturate(180%); }
}
.modal-content-wrapper {
    color: var(--text-primary);
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), 
               borderGlow 3s ease-in-out infinite;
}
@keyframes slideUp {
    from { transform: translateY(30px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Modal Content */
.modal-glass-bg {
    background: linear-gradient(135deg, 
        rgba(244, 247, 250, 0.9) 0%, 
        rgba(255, 255, 255, 0.85) 100%);
    backdrop-filter: blur(40px) saturate(200%);
}
body.dark .modal-glass-bg {
    background: linear-gradient(135deg, 
        rgba(15, 23, 42, 0.85) 0%, 
        rgba(30, 41, 59, 0.9) 100%);
    backdrop-filter: blur(40px) saturate(150%);
}
.modal-content-wrapper h3 { color: var(--text-primary); }
.modal-content-wrapper .dark\:text-white { color: var(--text-primary) !important; }
.modal-content-wrapper p,
.modal-content-wrapper .text-gray-900,
.modal-content-wrapper .dark\:text-gray-300 { color: var(--text-secondary); }

/* Modal Header Borders */
.modal-content-wrapper .bg-gradient-to-r.from-red-100\/50 {
     background: var(--bg-primary);
     border-color: var(--border-color);
}
body.dark .modal-content-wrapper .bg-gradient-to-r.from-red-100\/50 {
     background: var(--bg-secondary);
     border-color: var(--border-color);
}

/* Glass Columns */
.glass-column {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: none;
}
body.dark .glass-column {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}
.glass-column h4 {
    color: var(--text-primary);
    border-color: var(--border-color);
}
.glass-column p, .glass-column label, .glass-column span,
.glass-column .text-gray-700, .glass-column .dark\:text-gray-400,
.glass-column .text-gray-800, .glass-column .dark\:text-gray-200,
.glass-column .text-gray-600, .glass-column .dark\:text-gray-300 {
     color: var(--text-secondary);
}
.glass-column span[id$="Count"], .glass-column span[id$="Value"] {
     color: var(--text-primary);
     font-weight: 600;
}
/* Badges */
.glass-column span[id$="Count"].bg-gradient-to-r,
.modal-content-wrapper span[id$="Count"].bg-gradient-to-r,
.modal-content-wrapper span[id$="pageCount"].bg-gradient-to-r,
.modal-content-wrapper span[id$="fileCount"].bg-gradient-to-r,
.modal-content-wrapper span[id$="jpgPageCount"].bg-gradient-to-r,
.modal-content-wrapper span[id$="ocrPageCount"].bg-gradient-to-r,
.modal-content-wrapper span[id$="imageToPdfCount"].bg-gradient-to-r,
.modal-content-wrapper span[id$="mergeFileCount"].bg-gradient-to-r,
.modal-content-wrapper span[id$="compressFileCount"].bg-gradient-to-r {
     color: white !important;
     font-weight: 700;
}

/* Inputs in Modal */
.glass-column input[type="range"] {
     background: var(--border-color);
}
.bg-black\/5, .dark\:bg-black\/20 {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}
body.dark .bg-black\/5, body.dark .dark\:bg-black\/20 {
     background: var(--bg-secondary);
}

/* List Items */
.file-list-item, .page-card, .file-card {
     background: var(--bg-secondary);
}
.file-list-item:hover, .page-card:hover {
      background: var(--bg-secondary-hover);
}
.file-list-item p, .page-card p {
     color: var(--text-secondary);
}
.file-list-item p.font-semibold, .page-card p.font-bold,
body.dark .file-list-item p, 
body.dark .page-card p.font-bold {
     color: var(--text-primary) !important;
}
body.dark .file-list-item p.text-xs, 
body.dark .page-card p:not(.font-bold) {
    color: var(--text-secondary) !important; 
}

/* Footer in Modal */
.flex-shrink-0.px-6.py-4 {
     background: var(--bg-primary);
     border-color: var(--border-color);
}
body.dark .flex-shrink-0.px-6.py-4 {
      background: var(--bg-secondary);
}
.flex-shrink-0.px-6.py-4 span, .flex-shrink-0.px-6.py-4 div[id$="Status"],
.flex-shrink-0.px-6.py-4 .text-gray-800, .flex-shrink-0.px-6.py-4 .dark\:text-gray-300 {
     color: var(--text-tertiary) !important;
}
.flex-shrink-0.px-6.py-4 span[id*="StatusText"],
.flex-shrink-0.px-6.py-4 .text-gray-900, .flex-shrink-0.px-6.py-4 .dark\:text-white {
      color: var(--text-primary) !important;
      font-weight: 600;
}

/* Dropdowns */
select.styled-select, textarea,
select.styled-select.dark\:bg-gray-700, textarea.dark\:bg-gray-800 {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
body.dark select.styled-select, body.dark textarea {
     background-color: var(--bg-secondary-hover);
     border-color: var(--border-color);
     color: var(--text-primary);
}

/* Page Numbers */
.page-card .p-2 {
    border-color: var(--border-color);
}
.page-card .p-2 p {
     color: var(--text-secondary) !important;
}
.page-card .p-2 p.font-bold {
     color: var(--text-primary) !important;
     text-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
body.dark .page-card .p-2 p.font-bold {
    color: var(--text-primary) !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Animations & Effects */
@keyframes borderGlow {
    0%, 100% { border-color: rgba(239, 68, 68, 0.5); }
    50% { border-color: rgba(236, 72, 153, 0.7); }
}
.neon-red {
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}
.neon-border {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3),
                inset 0 0 20px rgba(239, 68, 68, 0.1);
}

/* Drag & Drop Styles */
.sortable-ghost {
    opacity: 0.4 !important;
    background: linear-gradient(135deg, 
        rgba(239, 68, 68, 0.2), 
        rgba(236, 72, 153, 0.2)) !important;
    backdrop-filter: blur(10px) !important;
    transform: scale(0.98) !important;
}
.sortable-drag {
    transform: scale(1.08) rotate(2deg) !important;
    box-shadow: 0 25px 50px -12px rgba(239, 68, 68, 0.5), 
                0 20px 25px -5px rgba(0, 0, 0, 0.3),
                0 0 30px rgba(239, 68, 68, 0.4) !important;
    z-index: 1000 !important;
    opacity: 1 !important;
}

/* Scrollbars */
#organizeFileList::-webkit-scrollbar,
#mergeFileGrid::-webkit-scrollbar,
#mergeFileListView::-webkit-scrollbar,
#imageToPdfPreview::-webkit-scrollbar,
#organizePagePreview::-webkit-scrollbar,
#jpgPagePreview::-webkit-scrollbar,
#compressFileList::-webkit-scrollbar,
#ocrPageList::-webkit-scrollbar,
#ocrTextOutput::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
#organizeFileList::-webkit-scrollbar-track,
#mergeFileGrid::-webkit-scrollbar-track,
#mergeFileListView::-webkit-scrollbar-track,
#imageToPdfPreview::-webkit-scrollbar-track,
#organizePagePreview::-webkit-scrollbar-track,
#jpgPagePreview::-webkit-scrollbar-track,
#compressFileList::-webkit-scrollbar-track,
#ocrPageList::-webkit-scrollbar-track,
#ocrTextOutput::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}
#organizeFileList::-webkit-scrollbar-thumb,
#mergeFileGrid::-webkit-scrollbar-thumb,
#mergeFileListView::-webkit-scrollbar-thumb,
#imageToPdfPreview::-webkit-scrollbar-thumb,
#organizePagePreview::-webkit-scrollbar-thumb,
#jpgPagePreview::-webkit-scrollbar-thumb,
#compressFileList::-webkit-scrollbar-thumb,
#ocrPageList::-webkit-scrollbar-thumb,
#ocrTextOutput::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #ef4444, #ec4899);
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}
#organizeFileList::-webkit-scrollbar-thumb:hover,
#mergeFileGrid::-webkit-scrollbar-thumb:hover,
#mergeFileListView::-webkit-scrollbar-thumb:hover,
#imageToPdfPreview::-webkit-scrollbar-thumb:hover,
#organizePagePreview::-webkit-scrollbar-thumb:hover,
#jpgPagePreview::-webkit-scrollbar-thumb:hover,
#compressFileList::-webkit-scrollbar-thumb:hover,
#ocrPageList::-webkit-scrollbar-thumb:hover,
#ocrTextOutput::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #dc2626, #db2777);
}
body.dark #organizeFileList::-webkit-scrollbar-track,
body.dark #mergeFileGrid::-webkit-scrollbar-track,
body.dark #mergeFileListView::-webkit-scrollbar-track,
body.dark #imageToPdfPreview::-webkit-scrollbar-track,
body.dark #organizePagePreview::-webkit-scrollbar-track,
body.dark #jpgPagePreview::-webkit-scrollbar-track,
body.dark #compressFileList::-webkit-scrollbar-track,
body.dark #ocrPageList::-webkit-scrollbar-track,
body.dark #ocrTextOutput::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

/* Interactive States */
.page-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.page-card:hover {
    transform: translateY(-5px) scale(1.02);
}

.file-card {
    position: relative;
    transition: all 0.3s ease;
}
.file-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 0.75rem;
    padding: 2px;
    background: linear-gradient(135deg, transparent, rgba(239, 68, 68, 0.3));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.file-card:hover::before {
    opacity: 1;
}

.file-list-item {
    transition: all 0.2s ease;
}
.file-list-item:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}
.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: .4s;
    border-radius: 28px;
}
body.dark .toggle-slider {
    background-color: #4b5563;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .toggle-slider {
    background-color: var(--accent);
}
input:checked + .toggle-slider:before {
    transform: translateX(22px);
}
body.dark input:checked + .toggle-slider {
   background-color: var(--accent);
}

/* Grips and Handles */
#organizeFileList .fa-grip-vertical,
#compressFileList .fa-grip-vertical,
.merge-list-handle .fa-grip-vertical,
.handle {
    padding: 0.75rem 0.75rem;
    cursor: grab;
    margin-left: -0.75rem;
    color: var(--text-tertiary);
    transition: color 0.2s;
}
#organizeFileList .fa-grip-vertical:hover,
#compressFileList .fa-grip-vertical:hover,
.merge-list-handle .fa-grip-vertical:hover,
.handle:hover {
    color: var(--text-primary);
}

.file-card .fa-grip-horizontal {
    padding: 0.75rem 0.75rem !important;
    cursor: grab;
    color: var(--text-tertiary);
    transition: color 0.2s;
}
.file-card .fa-grip-horizontal:hover {
    color: var(--text-primary);
}

/* Drag Over State */
.drag-over {
    transform: scale(1.02);
    border-color: var(--accent) !important;
    border-style: solid !important;
    background: rgba(239, 68, 68, 0.05);
}

/* Utils */
.enlarged-canvas {
    max-width: 85vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

body.modal-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .tool-card {
        padding: 1.5rem;
    }
}