/* SplitSmart - Simple PDF Tool Styles */

/* ============================================
   Base Styles
   ============================================ */

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding-bottom: 80px; /* Space for fixed nav buttons */
}

/* ============================================
   Accessibility
   ============================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

*:focus-visible {
    outline: 3px solid #15803D;
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   Step Indicator
   ============================================ */

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    background-color: #e5e7eb;
    color: #6b7280;
    transition: all 0.3s ease;
}

.step-circle.active {
    background-color: #15803D;
    color: white;
}

.step-circle.completed {
    background-color: #22C55E;
    color: white;
}

.step-circle.completed .step-number {
    display: none;
}

.step-circle.completed .step-check {
    display: block;
}

.step-label {
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    transition: color 0.3s ease;
}

.step-circle.active + .step-label,
.step-circle.completed + .step-label {
    color: #374151;
}

.step-line {
    width: 60px;
    height: 3px;
    background-color: #e5e7eb;
    margin: 0 8px;
    transition: background-color 0.3s ease;
}

.step-line.completed {
    background-color: #22C55E;
}

/* ============================================
   Drop Zone
   ============================================ */

.drop-zone {
    border: 3px dashed #d1d5db;
    border-radius: 16px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #fafafa;
}

.drop-zone:hover,
.drop-zone:focus {
    border-color: #15803D;
    background-color: #F0FDF4;
}

.drop-zone.drag-over {
    border-color: #15803D;
    background-color: #DCFCE7;
    transform: scale(1.02);
}

.drop-zone-icon {
    display: flex;
    justify-content: center;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.drop-zone.drag-over .drop-zone-icon {
    animation: none;
    transform: scale(1.1);
}

/* ============================================
   Buttons
   ============================================ */

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #15803D 0%, #166534 100%);
    color: white;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(21, 128, 61, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(21, 128, 61, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: white;
    color: #374151;
    font-weight: 600;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover:not(:disabled) {
    border-color: #15803D;
    color: #15803D;
    background-color: #F0FDF4;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background-color: #f3f4f6;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toolbar-btn:hover:not(:disabled) {
    background-color: #e5e7eb;
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tool-btn {
    padding: 8px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: transparent;
}

.tool-btn:hover {
    background-color: #e5e7eb;
}

.tool-btn.active {
    border-color: #15803D;
    background-color: #F0FDF4;
}

.nav-btn {
    padding: 10px;
    background-color: #f3f4f6;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover:not(:disabled) {
    background-color: #e5e7eb;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ============================================
   Thumbnail Grid
   ============================================ */

.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    padding-bottom: 24px;
}

.page-thumbnail {
    position: relative;
    background-color: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.page-thumbnail:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #9ca3af;
}

.page-thumbnail.selected {
    border-color: #3b82f6;
    border-width: 3px;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.page-thumbnail.deleted {
    opacity: 0.4;
    border-color: #ef4444;
}

.page-thumbnail canvas {
    width: 100%;
    height: auto;
    display: block;
}

.page-number {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.selection-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    background-color: #3b82f6;
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Split Line between thumbnails */
.split-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: #ef4444;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}

.split-line:hover {
    width: 6px;
    background-color: #dc2626;
}

.split-line::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background-color: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
}

/* Split zone between thumbnails */
.split-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 24px;
    cursor: pointer;
    z-index: 5;
    transition: background-color 0.2s ease;
}

.split-zone:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

/* ============================================
   Page Viewer (Redaction Step)
   ============================================ */

.page-viewer {
    height: calc(100vh - 320px);
    min-height: 400px;
    background: #374151;
    border-radius: 8px;
    overflow: auto;
}

#canvasContainer {
    min-width: 100%;
    display: flex;
    justify-content: center;
    padding: 24px;
}

#canvasWrapper {
    position: relative;
    display: inline-block;
    background: white;
}

.page-viewer canvas {
    display: block;
}

.redaction-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.redaction-layer.drawing {
    pointer-events: auto;
    cursor: crosshair;
}

.redaction-rect {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
}

.redaction-rect.redact {
    background-color: black;
}

.redaction-rect.whiteout {
    background-color: white;
}

.redaction-rect.highlight-yellow {
    background-color: rgba(253, 224, 71, 0.5);
}

.redaction-rect.highlight-green {
    background-color: rgba(134, 239, 172, 0.5);
}

.redaction-rect.highlight-pink {
    background-color: rgba(249, 168, 212, 0.5);
}

/* Thumbnail Strip */
.mini-thumbnail {
    width: 100%;
    aspect-ratio: 3/4;
    border: 2px solid #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.mini-thumbnail:hover {
    border-color: #9ca3af;
}

.mini-thumbnail.active {
    border-color: #15803D;
    border-width: 3px;
}

.mini-thumbnail canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   Modal
   ============================================ */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background-color: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlideUp 0.3s ease-out;
}

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

/* Help Tabs */
.help-tab {
    padding: 8px 16px;
    background-color: #f3f4f6;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.help-tab:hover {
    background-color: #e5e7eb;
    color: #374151;
}

.help-tab.active {
    background-color: #15803D;
    color: white;
}

.help-panel {
    animation: fadeIn 0.2s ease-out;
}

.help-panel.hidden {
    display: none;
}

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

/* Keyboard Shortcut Key */
.kbd {
    display: inline-block;
    padding: 4px 8px;
    background-color: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    margin-right: 6px;
}

/* ============================================
   Loading Overlay
   ============================================ */

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay.hidden {
    display: none;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #15803D;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* ============================================
   Toast Notifications
   ============================================ */

.toast {
    padding: 12px 16px;
    background-color: #374151;
    color: white;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: toastSlideIn 0.3s ease-out;
}

.toast.success {
    background-color: #15803D;
}

.toast.error {
    background-color: #dc2626;
}

.toast.warning {
    background-color: #d97706;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   Download Summary Cards
   ============================================ */

.download-card {
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.download-card-icon {
    width: 48px;
    height: 48px;
    background-color: #F0FDF4;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.download-card-info {
    flex: 1;
}

.download-card-title {
    font-weight: 600;
    color: #374151;
    margin-bottom: 2px;
}

.download-card-description {
    font-size: 14px;
    color: #6b7280;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 640px) {
    .step-circle {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .step-line {
        width: 24px;
    }

    .thumbnail-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }

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

    .modal-content {
        padding: 16px;
        max-height: 90vh;
    }
}

/* ============================================
   Custom Scrollbar
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================
   Download Preview Cards
   ============================================ */

#downloadSummary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.download-card {
    transition: all 0.2s ease;
}

.download-card:hover {
    border-color: #15803D;
    box-shadow: 0 4px 12px rgba(21, 128, 61, 0.1);
}

/* ============================================
   Page Context Indicator
   ============================================ */

#pageContext {
    transition: opacity 0.2s ease;
}

#pageContextText {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   Zoom Controls
   ============================================ */

#zoomLevel {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* Canvas wrapper shadow for PDF look */
#canvasWrapper {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Merged Groups
   ============================================ */

.merged-name-input {
    width: 200px;
    cursor: text;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.2s;
}

.merged-name-input:hover {
    border-bottom-color: #9333ea;
}

.merged-name-input:focus {
    border-bottom-color: #9333ea;
    border-bottom-style: solid;
}

/* ============================================
   Auth Modal
   ============================================ */

#authModal {
    display: flex;
    align-items: center;
    justify-content: center;
}

#authModal.hidden {
    display: none;
}

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

.animate-slide-up {
    animation: slideUp 0.3s ease-out;
}

/* Small loading spinner for buttons */
.loading-spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* User menu styles */
#userMenuBtn {
    position: relative;
}

#userDropdown {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 8px;
}

/* Mobile auth modal */
@media (max-width: 480px) {
    #authModal > div > div {
        margin: 16px;
        max-height: calc(100vh - 32px);
    }

    #loginRegisterView,
    #resetPasswordView {
        padding: 24px;
    }
}
