/* ========== Base & Animations ========== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}

* { box-sizing: border-box; }

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }
.dark ::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
}
.dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.25);
}

/* ========== PDF Tool Buttons ========== */
.pdf-tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 10px;
    color: #6b7280;
    background: transparent;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}
.pdf-tool-btn:hover {
    color: #374151;
    background: #f3f4f6;
}
.dark .pdf-tool-btn:hover {
    color: #d1d5db;
    background: #1f2937;
}
.pdf-tool-btn.active {
    color: #3b82f6;
    background: #eff6ff;
    border-color: #bfdbfe;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.dark .pdf-tool-btn.active {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(96, 165, 250, 0.3);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ========== Color Presets ========== */
.color-preset {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}
.color-preset:hover {
    transform: scale(1.15);
    border-color: rgba(0,0,0,0.2);
}
.dark .color-preset:hover {
    border-color: rgba(255,255,255,0.3);
}

/* ========== Color Input ========== */
input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
    cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* ========== Range Input ========== */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: #e5e7eb;
    outline: none;
}
.dark input[type="range"] {
    background: #374151;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* ========== Page Placeholder Spinner ========== */
.page-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}
.dark .page-placeholder {
    background: #1e293b;
}
.page-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.page-spinner-ring {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.dark .page-spinner-ring {
    border-color: #374151;
    border-top-color: #60a5fa;
}
.page-spinner-text {
    font-size: 12px;
    font-weight: 500;
    color: #9ca3af;
}
.dark .page-spinner-text {
    color: #6b7280;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== PDF Page Wrapper ========== */
.page-wrapper {
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.06);
    border-radius: 4px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.dark .page-wrapper {
    box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.2);
}
.page-wrapper:hover {
    box-shadow: 0 8px 30px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.08);
}
.page-wrapper canvas {
    display: block;
}
.fabric-overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
}

/* ========== Quill Editor Customization ========== */
#quill-editor .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid #f3f4f6;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 1rem 1rem 0 0;
}
.dark #quill-editor .ql-toolbar.ql-snow {
    background: #111827;
    border-bottom-color: #1f2937;
}
#quill-editor .ql-container.ql-snow {
    border: none;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.8;
}
#quill-editor .ql-editor {
    padding: 32px 40px;
    min-height: 500px;
    color: #1f2937;
}
.dark #quill-editor .ql-editor {
    color: #e5e7eb;
}
#quill-editor .ql-editor.ql-blank::before {
    color: #9ca3af;
    font-style: normal;
}
#quill-editor .ql-snow .ql-stroke {
    stroke: #6b7280;
}
#quill-editor .ql-snow .ql-fill {
    fill: #6b7280;
}
#quill-editor .ql-snow .ql-picker-label {
    color: #6b7280;
}
#quill-editor .ql-snow .ql-picker-options {
    background: white;
    border-color: #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.dark #quill-editor .ql-snow .ql-picker-options {
    background: #1f2937;
    border-color: #374151;
}
#quill-editor .ql-snow .ql-active .ql-stroke {
    stroke: #3b82f6;
}
#quill-editor .ql-snow .ql-active .ql-fill {
    fill: #3b82f6;
}
#quill-editor .ql-snow .ql-active {
    color: #3b82f6;
}
#quill-editor .ql-toolbar .ql-formats button {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    transition: background 0.15s;
}
#quill-editor .ql-toolbar .ql-formats button:hover {
    background: #e5e7eb;
}
.dark #quill-editor .ql-toolbar .ql-formats button:hover {
    background: #374151;
}
#quill-editor .ql-snow .ql-picker.ql-expanded .ql-picker-label {
    border-color: #3b82f6;
}
#quill-editor .ql-snow .ql-tooltip {
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
    border-color: #e5e7eb;
}
.dark #quill-editor .ql-snow .ql-tooltip {
    background: #1f2937;
    border-color: #374151;
}
.dark #quill-editor .ql-snow .ql-tooltip input {
    background: #111827;
    color: #e5e7eb;
}

/* ========== Toast ========== */
.toast {
    animation: toastIn 0.35s ease-out forwards;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    backdrop-filter: blur(12px);
}
.dark .toast {
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.toast-exit {
    animation: toastOut 0.3s ease-in forwards;
}

/* ========== Loading Overlay ========== */
#loading-overlay.hidden {
    display: none !important;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    #pdf-toolbar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        border-top: 1px solid rgba(0,0,0,0.1);
        border-right: none;
        z-index: 40;
        padding: 8px;
        gap: 8px;
    }
    #view-pdf {
        flex-direction: column;
    }
    #quill-editor .ql-editor {
        padding: 20px 24px;
    }
}
