/* Comic PDF Viewer - Modern Flat Design */

/* Import Gilroy Font from CDN */
@import url('https://fonts.cdnfonts.com/css/gilroy-bold');

/* Color Palette - Flat & Modern */
:root {
    --primary-color: #2563eb;        /* Blue 600 */
    --primary-hover: #1d4ed8;        /* Blue 700 */
    --primary-light: #dbeafe;        /* Blue 100 */
    --secondary-color: #64748b;      /* Slate 500 */
    --background: #f8fafc;           /* Slate 50 */
    --surface: #ffffff;              /* White */
    --border: #e2e8f0;               /* Slate 200 */
    --text-primary: #0f172a;         /* Slate 900 */
    --text-secondary: #475569;       /* Slate 600 */
    --error: #dc2626;                /* Red 600 */
    --error-bg: #fef2f2;             /* Red 50 */
    --success: #16a34a;              /* Green 600 */
}

/* Main Container - Full Width */
.comic-pdf-container {
    position: relative;
    margin: 20px auto;
    max-width: 98%;                  /* Aproape full-width */
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
    padding: 24px;
    border: 1px solid var(--border);
    font-family: 'Gilroy', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    box-sizing: border-box;
    overflow: hidden;
}

/* Pentru ecrane foarte mari */
@media (min-width: 1920px) {
    .comic-pdf-container {
        max-width: 96%;              /* Și mai larg pe ecrane 4K */
    }
}

/* Loading Spinner - Minimal */
.comic-pdf-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-secondary);
}

.comic-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.comic-pdf-loading p {
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Error Message - Flat */
.comic-pdf-error {
    text-align: center;
    padding: 24px;
    color: var(--error);
    background: var(--error-bg);
    border-radius: 6px;
    border: 1px solid var(--error);
    font-size: 15px;
}

/* Controls - Flat & Modern */
.comic-pdf-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Buttons - Flat Design */
.comic-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    user-select: none;
}

.comic-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--surface);
}

.comic-btn:active {
    transform: scale(0.95);
}

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

.comic-btn:disabled:hover {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-primary);
}

/* Page Info - Clean */
.comic-page-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--surface);
    border-radius: 6px;
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    min-width: 80px;
    justify-content: center;
}

.comic-page-current {
    color: var(--primary-color);
    font-size: 15px;
}

.comic-page-separator {
    color: var(--secondary-color);
}

.comic-page-total {
    color: var(--text-secondary);
}

/* Canvas Wrapper - Auto Height (se adaptează la PDF) */
.comic-pdf-canvas-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
    border: 1px solid var(--border);
    min-height: 400px;               /* Doar pentru loading, altfel auto */
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Canvas - Clean & Large */
.comic-pdf-canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto !important;
    height: auto !important;
    border-radius: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
    display: block;
    object-fit: contain;
}

.comic-pdf-canvas:active {
    cursor: grabbing;
}

/* Page Shadow - Minimal (aproape invizibil) */
.comic-page-shadow {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.comic-page-shadow::before,
.comic-page-shadow::after {
    display: none; /* Eliminăm shadow-urile pentru design flat */
}

/* Rotate Message - Mobile Portrait Only */
.comic-rotate-message {
    display: none; /* Ascuns by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    box-sizing: border-box;
}

.comic-rotate-icon {
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
    animation: rotatePhone 2s ease-in-out infinite;
}

.comic-rotate-icon svg {
    width: 100%;
    height: 100%;
    fill: var(--primary-color);
}

.comic-rotate-message h3 {
    font-size: 24px;
    color: var(--text-primary);
    margin: 0 0 16px 0;
    font-weight: 600;
}

.comic-rotate-message p {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

/* Animație rotire telefon */
@keyframes rotatePhone {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-15deg);
    }
    75% {
        transform: rotate(15deg);
    }
}

/* Animație puls pentru text */
@keyframes textPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.comic-rotate-message p {
    animation: textPulse 2s ease-in-out infinite;
}

/* Afișează mesajul DOAR pe mobile în portrait */
@media (max-width: 768px) and (orientation: portrait) {
    .comic-rotate-message {
        display: flex !important;
    }
    
    /* Ascunde tot restul conținutului în portrait */
    .comic-pdf-viewer,
    .comic-pdf-loading,
    .comic-pdf-error,
    .comic-pdf-controls {
        display: none !important;
    }
}

/* În landscape pe mobile, ascunde mesajul și arată conținutul */
@media (max-width: 768px) and (orientation: landscape) {
    .comic-rotate-message {
        display: none !important;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 768px) {
    .comic-pdf-container {
        padding: 16px;
        margin: 0;
        border-radius: 0;
        max-width: 100%;
        width: 100% !important;
        min-height: calc(100vh - 20px);
        height: auto;
        border-left: none;
        border-right: none;
    }
    
    .comic-pdf-controls {
        gap: 6px;
        padding: 10px;
        margin-bottom: 16px;
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--surface);
        border: 1px solid var(--border);
    }
    
    .comic-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
        flex-shrink: 0;
    }
    
    .comic-page-info {
        font-size: 13px;
        padding: 6px 12px;
        min-width: 70px;
        flex-shrink: 0;
    }
    
    .comic-pdf-canvas-wrapper {
        padding: 12px;
        min-height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .comic-pdf-canvas {
        max-width: 100%;
        max-height: 100%;
        width: auto !important;
        height: auto !important;
    }
    
    .comic-pdf-loading {
        min-height: calc(100vh - 80px);
        padding: 16px;
    }
    
    /* Optimizare pentru viewport mobile */
    @supports (-webkit-touch-callout: none) {
        .comic-pdf-container {
            min-height: -webkit-fill-available;
        }
        
        .comic-pdf-canvas-wrapper {
            min-height: calc(-webkit-fill-available - 100px);
            max-height: calc(-webkit-fill-available - 100px);
        }
    }
}

/* Tablet - și aici lățime maximă */
@media (min-width: 769px) and (max-width: 1024px) {
    .comic-pdf-container {
        padding: 20px;
        margin: 16px auto;
        max-width: 96%;              /* Aproape full-width pe tablet */
    }
    
    .comic-pdf-canvas-wrapper {
        padding: 20px;
        min-height: 400px;           /* Doar pentru loading */
    }
}

/* Prevent text selection and context menu */
.comic-pdf-container {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
}

.comic-pdf-container * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Mobile specific - permite swipe orizontal */
@media (max-width: 768px) {
    .comic-pdf-container {
        touch-action: pan-x pan-y;
    }
    
    .comic-pdf-canvas-wrapper {
        touch-action: pan-x pan-y;
    }
    
    .comic-magazine-spread {
        touch-action: pan-x pan-y;
    }
}

/* Disable image dragging */
.comic-pdf-canvas {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

/* Magazine Mode - Two Page Layout - Full Width */
.comic-magazine-mode .comic-pdf-canvas-wrapper {
    padding: 20px;
    gap: 0;
    overflow: visible;
    min-height: 400px;               /* Doar pentru loading, apoi auto */
}

.comic-magazine-spread {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.comic-page-left,
.comic-page-right {
    position: relative;
    flex: 1 1 calc(50% - 8px);
    max-width: calc(50% - 8px);
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    overflow: visible;
}

.comic-page-left {
    justify-content: flex-end;
}

.comic-page-right {
    justify-content: flex-start;
}

.comic-magazine-mode .comic-pdf-canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.comic-page-left .comic-pdf-canvas,
.comic-page-right .comic-pdf-canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    display: block;
}

/* Magazine Spine - Minimal & Flat */
.comic-magazine-spine {
    width: 2px;
    min-width: 2px;
    max-width: 2px;
    height: 100%;
    background: var(--border);
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    flex-grow: 0;
}

.comic-magazine-spine::before {
    display: none; /* Eliminăm decorațiile pentru design flat */
}

.comic-magazine-mode .comic-pdf-canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

.comic-magazine-mode .comic-page-shadow {
    display: none; /* Eliminăm shadow-urile în modul revistă */
}

.comic-page-left .comic-page-shadow::after,
.comic-page-right .comic-page-shadow::before {
    display: none;
}

/* Page Turn Animation - Subtle */
@keyframes pageTurnLeft {
    0% {
        transform: translateX(0);
        opacity: 1;
    }
    50% {
        transform: translateX(-4px);
        opacity: 0.8;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes pageTurnRight {
    0% {
        transform: translateX(0);
        opacity: 1;
    }
    50% {
        transform: translateX(4px);
        opacity: 0.8;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes pageTurnSingle {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.98);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.comic-page-left.page-turning {
    animation: pageTurnLeft 0.3s ease;
}

.comic-page-right.page-turning {
    animation: pageTurnRight 0.3s ease;
}

.comic-pdf-canvas-wrapper.page-turning .comic-pdf-canvas {
    animation: pageTurnSingle 0.3s ease;
}

/* Enhanced shadows during animation - Minimal pentru flat design */
.comic-page-left.page-turning .comic-pdf-canvas,
.comic-page-right.page-turning .comic-pdf-canvas {
    /* Păstrăm designul flat, fără shadow-uri extra */
}

/* Responsive for Magazine Mode */
@media (max-width: 768px) {
    .comic-magazine-mode .comic-pdf-canvas-wrapper {
        padding: 12px;
        min-height: calc(100vh - 120px);
        height: calc(100vh - 120px);
    }
    
    .comic-magazine-spread {
        flex-direction: column;
        gap: 12px;
        width: 100%;
        height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .comic-page-left,
    .comic-page-right {
        max-width: 100%;
        width: 100%;
        padding: 0;
        flex: 0 0 auto;
    }
    
    .comic-magazine-spine {
        width: 100%;
        height: 2px;
        background: var(--border);
        flex-shrink: 0;
    }
    
    .comic-magazine-spine::before {
        display: none;
    }
    
    .comic-magazine-mode .comic-pdf-canvas {
        max-width: 100%;
        max-height: 70vh;
        width: auto !important;
        height: auto !important;
    }
}

/* Focus States - pentru accesibilitate */
.comic-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f172a;           /* Slate 900 */
        --surface: #1e293b;              /* Slate 800 */
        --border: #334155;               /* Slate 700 */
        --text-primary: #f1f5f9;         /* Slate 100 */
        --text-secondary: #cbd5e1;       /* Slate 300 */
        --error-bg: #450a0a;             /* Red 950 */
    }
    
    .comic-pdf-container {
        background: var(--surface);
    }
    
    .comic-pdf-canvas {
        background: var(--surface);
    }
    
    .comic-rotate-message {
        background: var(--surface);
    }
}

/* Print Styles */
@media print {
    .comic-pdf-controls {
        display: none;
    }
    
    .comic-pdf-container {
        border: none;
        box-shadow: none;
        padding: 0;
        max-width: 100%;
    }
}
