/* Custom styles for e-paper platform */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --text-color: #2c3e50;
    --light-bg: #ecf0f1;
    --border-color: #bdc3c7;
}

body {
    font-family: 'Georgia', serif;
    background-color: var(--light-bg);
    color: var(--text-color);
}

/* Sidebar styles */
.sidebar-thumbnails {
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

.page-thumbnails {
    padding: 0 15px;
}

.thumbnail-item {
    position: relative;
    margin-bottom: 15px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 5px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.thumbnail-item:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.thumbnail-item.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.3);
}

.thumbnail-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.thumbnail-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
    padding: 8px;
    text-align: center;
}

/* Main content styles */
.main-content {
    min-height: 100vh;
}

.toolbar {
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.page-viewer-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 70vh;
    padding: 20px;
}

.page-viewer {
    position: relative;
    display: inline-block;
    max-width: 100%;
    background: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border-radius: 8px;
    overflow: hidden;
}

.page-image {
    max-width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    cursor: grab;
}

.page-image:active {
    cursor: grabbing;
}

/* Crop overlay styles */
.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    cursor: crosshair;
    z-index: 10;
}

.crop-selection {
    position: absolute;
    border: 2px dashed #fff;
    background: rgba(255,255,255,0.1);
    min-width: 50px;
    min-height: 50px;
    cursor: move;
}

.crop-handles {
    position: relative;
    width: 100%;
    height: 100%;
}

.crop-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    cursor: grab;
}

.crop-handle:active {
    cursor: grabbing;
}

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

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

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

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

.crop-controls {
    text-align: center;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Button styles */
.btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-primary {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.btn-outline-primary:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

/* Social sharing buttons */
.btn-primary { background-color: #1877f2; border-color: #1877f2; }
.btn-info { background-color: #1da1f2; border-color: #1da1f2; }
.btn-success { background-color: #25d366; border-color: #25d366; }

/* Responsive design */
@media (max-width: 768px) {
    .sidebar-thumbnails {
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .thumbnail-item {
        display: inline-block;
        width: 80px;
        margin-right: 10px;
        margin-bottom: 10px;
    }
    
    .thumbnail-item img {
        height: 60px;
    }
    
    .toolbar .row > div {
        margin-bottom: 10px;
    }
    
    .toolbar .col-md-6:last-child {
        text-align: center !important;
    }
    
    .page-viewer-container {
        padding: 10px;
    }
}

@media (max-width: 576px) {
    .btn-group .btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.875rem;
    }
    
    .btn-group .btn i {
        margin-right: 0;
    }
    
    .btn-group .btn span {
        display: none;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* Print styles */
@media print {
    .sidebar-thumbnails,
    .toolbar,
    .crop-controls,
    nav,
    footer {
        display: none !important;
    }
    
    .main-content {
        width: 100% !important;
        margin: 0 !important;
    }
    
    .page-viewer-container {
        justify-content: flex-start;
        padding: 0;
    }
    
    .page-image {
        max-width: 100%;
        box-shadow: none;
    }
}

/* Accessibility improvements */
.btn:focus,
.thumbnail-item:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

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

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
