/* Custom styles for E-Paper application */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Sidebar Styles */
.sidebar {
    background: #fff;
    height: 150vh;
    overflow-y: auto;
    z-index: 1000;
    transition: all 0.3s ease;
}

.sidebar-header {
    background: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.page-navigation {
    padding: 0;
}

.page-link {
    display: block;
    padding: 15px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.page-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.page-link.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-left: 4px solid white;
}

.page-thumbnail {
    text-align: center;
}

.page-thumbnail img {
    max-width: 150px;
    height: auto;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    margin-bottom: 8px;
    transition: transform 0.2s ease;
}

.page-link:hover .page-thumbnail img {
    transform: scale(1.05);
    border-color: white;
}

.page-number {
    font-size: 0.9rem;
    font-weight: 500;
    color:#000;
}

/* Main Content Styles */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.viewer-controls {
    background: #f8f9fa !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.pdf-viewer {
    background: #e9ecef;
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pdf-page-container {
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
    transition: transform 0.3s ease;
}

.pdf-page {
    display: block;
    width: 100%;
    height: auto;
    max-width: 800px;
}

.no-paper-message {
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Responsive Styles */
@media (max-width: 768px) {
    .sidebar {
        display:none;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .viewer-controls .row > div {
        margin-bottom: 10px;
    }
    
    .page-controls {
        text-align: center;
    }
    
    .zoom-controls {
        text-align: center !important;
    }
}

@media (max-width: 576px) {
    .viewer-controls {
        padding: 10px !important;
    }
    
    .viewer-controls .btn {
        font-size: 0.875rem;
        padding: 0.375rem 0.75rem;
    }
    
    .pdf-viewer {
        padding: 10px;
    }
}

/* Button Styles */
.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-secondary:hover {
    background-color: #6c757d;
    border-color: #6c757d;
}

/* Navbar Override */
.navbar-dark .navbar-brand {
    font-weight: 600;
    font-size: 1.5rem;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Zoom Styles */
.pdf-page.zoomed {
    cursor: grab;
}

.pdf-page.zoomed:active {
    cursor: grabbing;
}

/* Mobile Navigation Toggle */
.mobile-nav-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .mobile-nav-toggle {
        display: none;
    }
}

/* Crop Functionality Styles */
.pdf-page-container {
    position: relative;
    display: inline-block;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    z-index: 10;
}

.crop-selection {
    position: absolute;
    border: 2px dashed var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
    min-width: 20px;
    min-height: 20px;
}

.crop-handles {
    position: relative;
    width: 100%;
    height: 100%;
}

.crop-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
}

.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-mode {
    cursor: crosshair !important;
}

.crop-mode .pdf-page {
    cursor: crosshair !important;
}

/* Sub-pages Styles */
.subpages-section {
    background: #f8f9fa;
    padding: 20px 0;
    border-radius: 10px;
}

.subpage-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.subpage-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.subpage-card .card-body {
    padding: 15px;
}

/* Share Modal Styles */
#sharePreview {
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-whatsapp {
    background-color: #25D366;
    border-color: #25D366;
}

.btn-whatsapp:hover {
    background-color: #1ebe57;
    border-color: #1ebe57;
}

/* Enhanced Share Modal Styles */
.modal-header h5 {
    font-weight: 600;
}

#shareModal .modal-body h6 {
    color: #6c757d;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 20px;
    margin-bottom: 15px;
}

#shareModal .btn {
    font-weight: 500;
    border-radius: 8px;
    padding: 10px 16px;
    transition: all 0.3s ease;
}

#shareModal .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#downloadImage {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
}

#downloadImage:hover {
    background: linear-gradient(135deg, #218838 0%, #1ea575 100%);
}

#nativeShare {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
}

#nativeShare:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
}

#copyUrl {
    border-radius: 0 8px 8px 0 !important;
}

.share-section {
    padding: 15px 0;
    border-top: 1px solid #e9ecef;
    margin-top: 10px;
}

.share-section:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

/* Social media button colors */
#shareFacebook {
    background-color: #1877f2;
    border-color: #1877f2;
}

#shareFacebook:hover {
    background-color: #166fe5;
    border-color: #166fe5;
}

#shareTwitter {
    background-color: #1da1f2;
    border-color: #1da1f2;
}

#shareTwitter:hover {
    background-color: #0d8bd9;
    border-color: #0d8bd9;
}

#shareEmail {
    background-color: #6c757d;
    border-color: #6c757d;
}

#shareEmail:hover {
    background-color: #5a6268;
    border-color: #5a6268;
}

/* Crop Canvas Styles */
#cropCanvas {
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Responsive improvements for crop */
@media (max-width: 768px) {
    .crop-overlay {
        touch-action: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    .crop-handle {
        width: 20px;
        height: 20px;
        background: rgba(0, 123, 255, 0.8);
        border: 2px solid white;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    }
    
    .crop-handle.nw {
        top: -10px;
        left: -10px;
    }
    
    .crop-handle.ne {
        top: -10px;
        right: -10px;
    }
    
    .crop-handle.sw {
        bottom: -10px;
        left: -10px;
    }
    
    .crop-handle.se {
        bottom: -10px;
        right: -10px;
    }
    
    /* Better selection area visibility on mobile */
    .crop-selection {
        border: 2px solid #007bff;
        background: rgba(0, 123, 255, 0.1);
        min-width: 30px;
        min-height: 30px;
    }
    
    /* Touch-friendly controls */
    .viewer-controls .btn {
        padding: 12px 16px;
        margin: 2px;
        font-size: 16px;
    }
    
    /* Larger crop button for mobile */
    #cropBtn {
        min-width: 100px;
        font-weight: 600;
    }
    
    /* Better modal for mobile crop */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    #cropCanvas {
        max-width: 100%;
        height: auto;
    }
}

/* Mobile-specific improvements */
.mobile-device .crop-overlay {
    cursor: crosshair;
}

.mobile-device .crop-selection {
    border: 3px solid #007bff !important;
    background: rgba(0, 123, 255, 0.15) !important;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3);
}

.mobile-device .crop-mode .pdf-page {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Better button styling for mobile */
.mobile-device .btn {
    min-height: 44px;
    font-size: 16px;
    border-radius: 8px;
}

.mobile-device #cropBtn {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border: none;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
}

.mobile-device #cropBtn:hover,
.mobile-device #cropBtn:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.4);
}

.mobile-device #cropBtn.btn-outline-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: none;
}

/* Touch-friendly modal */
.mobile-device .modal-content {
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.mobile-device .modal-header {
    border-radius: 12px 12px 0 0;
}

.mobile-device .modal-footer .btn {
    min-width: 80px;
    margin: 5px;
}

/* Better crop instruction for mobile */
.mobile-device .crop-overlay::before {
    content: "Tap and drag to select area";
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 10;
    pointer-events: none;
}

.mobile-device .crop-mode .crop-overlay::before {
    animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    20% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* Crop Control Panel Styles */
.crop-control-panel {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95) 0%, rgba(33, 37, 41, 0.95) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: absolute !important;
    z-index: 1500;
}

.crop-control-panel .crop-info {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.crop-control-panel .crop-dimensions {
    font-size: 14px;
    font-weight: 600;
}

.crop-control-panel .crop-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.crop-control-panel .btn {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 15px;
    border: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.crop-control-panel .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Arrow for crop controls */
.crop-arrow {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Enhanced crop selection for adjustment */
.crop-selection {
    cursor: move;
    transition: all 0.2s ease;
    position: relative;
}

.crop-selection:hover {
    border-color: #007bff !important;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
}

.crop-handle {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 50%;
}

.crop-handle:hover {
    background: #007bff !important;
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.4);
}

.crop-handle.nw,
.crop-handle.se {
    cursor: nw-resize;
}

.crop-handle.ne,
.crop-handle.sw {
    cursor: ne-resize;
}

/* Mobile improvements for crop controls */
@media (max-width: 768px) {
    .crop-control-panel {
        min-width: 250px !important;
        padding: 14px 18px !important;
        border-radius: 15px !important;
        font-size: 14px;
    }
    
    .crop-control-panel .btn {
        padding: 8px 14px;
        font-size: 13px;
        min-width: 60px;
        border-radius: 12px;
    }
    
    .crop-control-panel .crop-actions {
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .crop-control-panel .crop-info {
        margin-bottom: 12px;
        padding-bottom: 10px;
    }
    
    .crop-control-panel .crop-dimensions {
        font-size: 15px;
        font-weight: 700;
    }
    
    .crop-handle {
        width: 24px !important;
        height: 24px !important;
        border: 3px solid white !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
    }
    
    .crop-handle.nw {
        top: -12px !important;
        left: -12px !important;
    }
    
    .crop-handle.ne {
        top: -12px !important;
        right: -12px !important;
    }
    
    .crop-handle.sw {
        bottom: -12px !important;
        left: -12px !important;
    }
    
    .crop-handle.se {
        bottom: -12px !important;
        right: -12px !important;
    }
    
    /* Larger selection area visibility on mobile */
    .mobile-device .crop-selection {
        border: 3px solid #007bff !important;
        background: rgba(0, 123, 255, 0.12) !important;
        box-shadow: 0 0 15px rgba(0, 123, 255, 0.4) !important;
    }
    
    /* Better arrow for mobile */
    .crop-arrow {
        border-left-width: 8px !important;
        border-right-width: 8px !important;
        border-bottom-width: 10px !important;
        border-top-width: 10px !important;
    }
}
