/* ========================================
   Corporate Professional PDF Editor Styles
   ======================================== */

/* CSS Variables for Corporate Theme */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --light-bg: #ecf0f1;
    --dark-bg: #1a252f;
    --text-primary: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #bdc3c7;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --guide-color: #ff2d95;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

/* Main Container Layout */
.main-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--light-bg);
}

/* ========================================
   Header Styles
   ======================================== */
.app-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 0.75rem 0;
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.app-brand i {
    font-size: 1.5rem;
    color: var(--accent-color);
}

.brand-name {
    letter-spacing: -0.5px;
}

.header-actions .btn {
    border-color: rgba(255, 255, 255, 0.3);
}

.header-actions .btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* ========================================
   Toolbar Styles
   ======================================== */
.toolbar {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0;
    box-shadow: var(--shadow-sm);
    z-index: 999;
}

.toolbar-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.toolbar-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-light);
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

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

.toolbar .btn {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.toolbar .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.toolbar .btn:active:not(:disabled) {
    transform: translateY(0);
}

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

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zoom-level {
    min-width: 50px;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* ========================================
   Content Area Styles
   ======================================== */
.content-area {
    flex: 1;
    overflow: auto;
    background: #f8f9fa;
    position: relative;
}

/* Custom Scrollbar */
.content-area::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.content-area::-webkit-scrollbar-track {
    background: #e9ecef;
}

.content-area::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 5px;
}

.content-area::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

/* ========================================
   Upload Area Styles
   ======================================== */
.upload-area {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
}

.upload-box {
    border: 3px dashed var(--border-color);
    border-radius: 1rem;
    padding: 3rem 2rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.upload-box:hover {
    border-color: var(--accent-color);
    background: #f8f9fa;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.upload-box.dragover {
    border-color: var(--success-color);
    background: rgba(39, 174, 96, 0.05);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    color: var(--accent-color);
    margin-bottom: 1.5rem;
    animation: float 3s ease-in-out infinite;
}

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

.upload-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-subtitle {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* ========================================
   PDF Viewer Styles
   ======================================== */
.pdf-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    min-height: 100%;
}

.pdf-page {
    background: white;
    box-shadow: var(--shadow-lg);
    position: relative;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.pdf-page:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.pdf-page canvas {
    display: block;
}

/* Page Controls */
.page-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pdf-page:hover .page-controls {
    opacity: 1;
}

.page-controls button {
    background: rgba(44, 62, 80, 0.9);
    backdrop-filter: blur(10px);
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.page-controls button:hover {
    background: rgba(44, 62, 80, 1);
    transform: scale(1.05);
}

/* Page Number Badge */
.page-number {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(44, 62, 80, 0.9);
    backdrop-filter: blur(10px);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pdf-page:hover .page-number {
    opacity: 1;
}

/* ========================================
   Image Overlay Styles
   ======================================== */
.image-overlay {
    position: absolute;
    cursor: move;
    border: 2px solid var(--accent-color);
    z-index: 5;
    overflow: visible;
    transition: border-color 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.image-overlay img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    user-select: none;
    display: block;
}

.image-overlay.selected {
    border-color: var(--success-color);
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.2), 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--success-color);
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.resize-handle:hover {
    background: #229954;
    transform: scale(1.2);
}

.resize-handle.nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

/* Delete Handle */
.delete-handle {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: var(--danger-color);
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
    z-index: 11;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.delete-handle:hover {
    background: #c0392b;
    transform: scale(1.15);
}

/* Alignment / Snap Guides */
.align-guide {
    position: absolute;
    background: var(--guide-color);
    z-index: 20;
    pointer-events: none;
}

.align-guide-vertical {
    top: 0;
    bottom: 0;
    width: 1px;
}

.align-guide-horizontal {
    left: 0;
    right: 0;
    height: 1px;
}

/* Image Context Menu */
.image-context-menu {
    position: fixed;
    z-index: 2000;
    background: white;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    min-width: 230px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid var(--border-color);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    background: none;
    border: none;
    border-radius: 0.35rem;
    text-align: left;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease;
}

.context-menu-item:hover {
    background: var(--light-bg);
}

.context-menu-item.danger {
    color: var(--danger-color);
}

.context-menu-item.danger:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* Size Match Mode */
body.size-match-mode .image-overlay {
    cursor: copy;
}

body.size-match-mode .image-overlay:not(.selected) {
    outline: 2px dashed var(--accent-color);
    outline-offset: 3px;
}

.size-match-banner {
    position: fixed;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 2rem;
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* ========================================
   Status Bar Styles
   ======================================== */
.status-bar {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 0.5rem 0;
    font-size: 0.875rem;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-light);
}

.status-indicator {
    font-size: 0.5rem;
    color: var(--success-color);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ========================================
   Loading Overlay Styles
   ======================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-content {
    background: white;
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .toolbar-content {
        gap: 0.5rem;
    }

    .toolbar-divider {
        display: none;
    }

    .toolbar-label {
        display: none;
    }

    .toolbar .btn span {
        display: none;
    }

    .toolbar .btn {
        padding: 0.375rem 0.5rem;
    }

    .app-brand .brand-name {
        font-size: 1rem;
    }

    .app-brand .badge {
        display: none;
    }

    .pdf-viewer {
        padding: 1rem;
        gap: 1rem;
    }

    .upload-box {
        padding: 2rem 1rem;
    }

    .upload-title {
        font-size: 1.25rem;
    }
}

@media (max-width: 576px) {
    .app-brand i {
        font-size: 1.25rem;
    }

    .app-brand .brand-name {
        font-size: 0.875rem;
    }

    .toolbar .btn {
        font-size: 0.75rem;
    }

    .zoom-level {
        font-size: 0.75rem;
        min-width: 45px;
    }
}

/* ========================================
   Utility Classes
   ======================================== */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Print Styles */
@media print {
    .app-header,
    .toolbar,
    .status-bar,
    .page-controls,
    .page-number {
        display: none !important;
    }

    .pdf-page {
        box-shadow: none;
        page-break-after: always;
    }
}
