/* =====================================================
   PDF Editor Pro - Stylesheet
   Matching MixOfAll theme with purple gradient
   ===================================================== */

/* CSS Variables */
:root {
    --primary-start: #667eea;
    --primary-end: #764ba2;
    --primary-gradient: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-end) 100%);
    --success-color: #22c55e;
    --success-gradient: linear-gradient(135deg, #22c55e, #16a34a);
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-dark: #1a1a2e;
    --bg-darker: #16213e;
    --bg-light: #f8fafc;
    --text-light: #ffffff;
    --text-dark: #1f2937;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

/* Base Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-darker) 50%, #0f3460 100%);
    color: var(--text-light);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* =====================================================
   App Layout
   ===================================================== */
.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-center {
    flex: 1;
    text-align: center;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.doc-name {
    color: var(--text-muted);
    font-size: 14px;
}

/* =====================================================
   Buttons
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-success {
    background: var(--success-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.5);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-full {
    width: 100%;
    margin-bottom: 10px;
}

.btn-full:last-child {
    margin-bottom: 0;
}

/* =====================================================
   Toolbar
   ===================================================== */
.toolbar {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.toolbar-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toolbar-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.tool-group {
    display: flex;
    gap: 4px;
}

.toolbar-divider {
    width: 1px;
    height: 50px;
    background: var(--border-color);
    margin: 0 8px;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 60px;
}

.tool-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    color: var(--primary-start);
}

.tool-btn.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.tool-icon {
    font-size: 20px;
    line-height: 1;
}

.tool-text {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =====================================================
   Mode Banner
   ===================================================== */
.mode-banner {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.1));
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fbbf24;
    font-size: 14px;
}

.mode-banner.edit-mode {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.1));
    border-color: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

.mode-banner.delete-mode {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.1));
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.mode-icon {
    font-size: 18px;
}

.mode-text {
    flex: 1;
}

.mode-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.7;
}

.mode-close:hover {
    opacity: 1;
}

/* =====================================================
   Main Content Area
   ===================================================== */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-area {
    flex: 1;
    overflow: auto;
}

/* =====================================================
   Upload Section
   ===================================================== */
.upload-section {
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.upload-card {
    text-align: center;
    margin-bottom: 60px;
}

.upload-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.upload-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 10px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.upload-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 30px;
}

.upload-box {
    max-width: 500px;
    margin: 0 auto 20px;
    padding: 50px;
    border: 2px dashed rgba(102, 126, 234, 0.5);
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-box:hover,
.upload-box.dragover {
    border-color: var(--primary-start);
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-5px);
}

.upload-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.upload-icon-small {
    font-size: 48px;
    opacity: 0.6;
}

.upload-or {
    color: var(--text-muted);
    font-size: 14px;
}

.upload-hint {
    color: var(--text-muted);
    font-size: 13px;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

.feature-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 30px;
    text-align: center;
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(102, 126, 234, 0.3);
}

.feature-icon {
    font-size: 40px;
    margin-bottom: 15px;
}

.feature-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.feature-card p {
    color: var(--text-muted);
    font-size: 14px;
}

/* =====================================================
   Editor Section
   ===================================================== */
.editor-section {
    height: calc(100vh - 140px);
    overflow: hidden;
}

.editor-container {
    display: flex;
    height: 100%;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    overflow: auto;
    padding: 30px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: rgba(0, 0, 0, 0.2);
}

.canvas-wrapper {
    position: relative;
    background: white;
    box-shadow: var(--shadow-lg);
    border-radius: 4px;
}

#pdfCanvas {
    display: block;
}

/* Text Layer */
.text-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.text-layer.active {
    pointer-events: auto;
}

.text-layer .text-item {
    position: absolute;
    cursor: pointer;
    white-space: pre;
    user-select: none;
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: 2px;
    transition: all 0.15s ease;
}

.text-layer.edit-mode .text-item {
    background: rgba(102, 126, 234, 0.1);
    border: 1px dashed rgba(102, 126, 234, 0.4);
}

.text-layer.edit-mode .text-item:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: var(--primary-start);
}

.text-layer.edit-mode .text-item.editing {
    background: #fffde7;
    border: 2px solid var(--primary-start);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    z-index: 100;
}

.text-layer.edit-mode .text-item.modified {
    background: rgba(34, 197, 94, 0.15);
    border-color: var(--success-color);
}

.text-layer.delete-mode .text-item {
    background: rgba(239, 68, 68, 0.1);
    border: 1px dashed rgba(239, 68, 68, 0.4);
}

.text-layer.delete-mode .text-item:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger-color);
}

.text-layer .text-item.deleted {
    background: rgba(239, 68, 68, 0.3) !important;
    text-decoration: line-through;
    opacity: 0.5;
}

/* Annotation Layer */
.annotation-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.annotation-layer.active {
    pointer-events: auto;
    cursor: crosshair;
}

.annotation {
    position: absolute;
    pointer-events: auto;
}

.annotation.highlight {
    background: rgba(255, 255, 0, 0.4);
}

.annotation.redact {
    background: #000;
}

.annotation.whiteout {
    background: #fff;
}

.annotation.text-annotation {
    background: #fffde7;
    border: 1px solid #ffd54f;
    padding: 8px 12px;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    color: #333;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    min-width: 100px;
}

.annotation.signature {
    cursor: move;
}

.annotation.signature img {
    max-width: 100%;
    max-height: 100%;
    pointer-events: none;
}

.annotation.check-mark,
.annotation.cross-mark {
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

.annotation.check-mark {
    color: var(--success-color);
}

.annotation.cross-mark {
    color: var(--danger-color);
}

.annotation .delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.annotation:hover .delete-btn {
    display: flex;
}

/* =====================================================
   Right Panel
   ===================================================== */
.right-panel {
    width: 280px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 1px solid var(--border-color);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.panel-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Page Navigation */
.page-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.nav-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
    background: var(--primary-gradient);
}

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

.page-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.page-info input {
    width: 50px;
    padding: 6px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: white;
    font-family: inherit;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.zoom-level {
    min-width: 60px;
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
}

/* Document Info */
.doc-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.info-label {
    color: var(--text-muted);
}

.info-value {
    color: white;
    font-weight: 500;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Edit Stats */
.edit-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-item {
    text-align: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
}

.stat-icon {
    font-size: 20px;
    display: block;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    display: block;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Thumbnails */
.thumbnail-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.thumbnail-item {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.thumbnail-item:hover {
    border-color: rgba(102, 126, 234, 0.5);
}

.thumbnail-item.active {
    border-color: var(--primary-start);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.thumbnail-item canvas {
    width: 100%;
    display: block;
    border-radius: 4px;
}

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

/* =====================================================
   Modals
   ===================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: white;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Signature Canvas */
#signatureCanvas {
    width: 100%;
    height: 150px;
    background: white;
    border-radius: var(--radius-sm);
    cursor: crosshair;
    touch-action: none;
}

.signature-colors {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

.color-btn {
    width: 36px;
    height: 36px;
    border: 3px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.color-btn.active {
    border-color: white;
    transform: scale(1.1);
}

/* Text Modal */
#textInput {
    width: 100%;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

#textInput:focus {
    outline: none;
    border-color: var(--primary-start);
}

.text-options {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    align-items: center;
}

.text-options select {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: white;
    font-family: inherit;
}

.text-options input[type="color"] {
    width: 40px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* =====================================================
   Footer
   ===================================================== */
.app-footer {
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid var(--border-color);
    padding: 15px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-muted);
}

.app-footer a {
    color: var(--primary-start);
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}

/* =====================================================
   Toast Notifications
   ===================================================== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(30, 30, 50, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

.toast.info {
    border-left: 4px solid var(--primary-start);
}

/* =====================================================
   Loading Overlay
   ===================================================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-start);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 1024px) {
    .right-panel {
        width: 250px;
    }
}

@media (max-width: 768px) {
    .right-panel {
        display: none;
    }

    .editor-container {
        flex-direction: column;
    }

    .canvas-area {
        padding: 15px;
    }

    .toolbar {
        justify-content: center;
    }

    .toolbar-divider {
        display: none;
    }
}