/*
Theme Name: ePaper By AddsMint
Theme URI: https://addsmint.com
Author: AddsMint
Author URI: https://addsmint.com
Description: Professional daily newspaper theme with Urdu/English support, bulk upload, and archive system
Version: 2.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: khabardar-newspaper
*/

/* ==========================================================================
   GLOBAL STYLES
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #ffffff;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
}

img {
    max-width: 100%;
    height: auto;
}

/* Urdu Font Support */
body.lang-urdu,
body.lang-urdu * {
    font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', 'Urdu Typesetting', serif;
    direction: rtl;
}

body.lang-english {
    direction: ltr;
}

/* ==========================================================================
   HEADER
   ========================================================================== */

.site-header {
    background: #e8e8e8;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
}

.header-main {
    background: #fff;
    padding: 20px 0;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

/*
 * LOGO RULE:
 * Control logo size with max-height ONLY.
 * width: auto lets the browser scale proportionally.
 * Never set a fixed width on a logo.
 */
.site-logo,
.custom-logo-link {
    display: inline-block;
    line-height: 0;
}

.site-logo img,
.custom-logo-link img,
img.custom-logo {
    max-height: 100px;
    height: auto;
    width: auto;
}

.site-title {
    font-size: 48px;
    font-weight: bold;
    color: #c41e3a;
    margin: 0;
}

/* Main Navigation */
.main-navigation {
    background: #2c2c2c;
    border-top: 3px solid #c41e3a;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    display: block;
    padding: 15px 20px;
    color: #fff;
    text-decoration: none;
    font-size: 16px;
    transition: background 0.3s;
}

.nav-menu a:hover,
.nav-menu li.current-menu-item a {
    background: #ebe8e9;
}

/* RTL Navigation */
body.lang-urdu .nav-menu {
    flex-direction: row-reverse;
}

/* ==========================================================================
   NEWSPAPER VIEWER CONTAINER
   ========================================================================== */

.newspaper-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    background: #fff;
}

/* Viewer Controls Bar */
.viewer-controls-bar {
    background: #2c2c2c;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    direction: ltr !important;
}

.newspaper-title-display {
    flex: 1;
    text-align: center;
}

.newspaper-title-display h2 {
    margin: 0;
    font-size: 1.2em;
    color: #ffffff;
    font-weight: bold;
}

.viewer-tab-buttons {
    display: flex;
    gap: 5px;
}

.tab-btn {
    padding: 10px 20px;
    background-color: #000;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s;
}

.tab-btn:hover,
.tab-btn.active {
    background-color: #fff !important;
}

.date-selector {
    background-color: #fff;
    padding: 8px 15px;
    border: none;
    border-radius: 3px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-selector input[type="date"] {
    border: 1px solid #ddd;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 14px;
    cursor: pointer;
}

/* Page Thumbnails Bar */
.page-thumbnails-bar {
    background: #f5f5f5;
    padding: 15px 20px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    border-bottom: 2px solid #ddd;
}

.page-thumb-item {
    flex-shrink: 0;
    width: 100px;
    position: relative;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s;
    text-decoration: none;
}

.page-thumb-item:hover {
    border-color: #999;
    transform: translateY(-3px);
}

.page-thumb-item.active {
    border-color: #c41e3a;
}

.page-thumb-item img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.page-thumb-label {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 3px;
    white-space: nowrap;
}

/* Main Newspaper Display Area */
.newspaper-display-area {
    background: transparent !important;
    padding: 0 !important;
    min-height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.newspaper-image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.newspaper-main-image {
    max-width: 100%;
    height: auto;
    display: block;
/*     box-shadow: 0 5px 25px rgba(0,0,0,0.3); */
    background: #fff;
}

/* Magnifier Glass */
.magnifier-glass {
    position: absolute;
    border: 3px solid #000;
    cursor: none;
    width: 300px !important;
    height: 250px !important;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    background-repeat: no-repeat;
    background-color: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    z-index: 100;
}

.newspaper-image-wrapper:hover .magnifier-glass {
    opacity: 1;
}

/* Page Navigation */
.page-navigation {
    position: absolute;
    top: 50%;
    left: 20px;
    right: 20px;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

.nav-arrow {
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    transition: all 0.3s;
}

.nav-arrow:hover:not(:disabled) {
    background: #c41e3a;
    transform: scale(1.1);
}

.nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ==========================================================================
   ARCHIVE SYSTEM
   ========================================================================== */

.archive-calendar {
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
    background: #fff;
}

.archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.archive-item {
    background: #fff;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s;
    cursor: pointer;
}

.archive-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border-color: #c41e3a;
}

.archive-thumb {
    width: 100%;
    height: 320px;
    overflow: hidden;
    background: #f5f5f5;
}

.archive-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.archive-item:hover .archive-thumb img {
    transform: scale(1.1);
}

.archive-info {
    padding: 20px;
    text-align: center;
}

.archive-date {
    font-size: 1.2em;
    font-weight: bold;
    color: #c41e3a;
    margin-bottom: 10px;
}

.archive-title {
    font-size: 1em;
    color: #333;
    margin-bottom: 10px;
}

.archive-pages-count {
    color: #666;
    font-size: 0.9em;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.site-footer {
    background: #e8e8e8;
    color: #333;
    text-align: center;
    padding: 30px 20px;
    margin-top: 60px;
    border-top: 3px solid #c41e3a;
}

.footer-content p {
    margin: 8px 0;
    line-height: 1.8;
}

.footer-content a {
    color: #c41e3a;
    text-decoration: none;
    font-weight: bold;
}

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

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.no-newspaper {
    padding: 100px 20px;
    text-align: center;
    background: #f9f9f9;
}

.no-newspaper h2 {
    font-size: 2em;
    color: #666;
    margin-bottom: 20px;
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    background: #c41e3a;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
    font-size: 16px;
}

.btn:hover {
    background: #a01729;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(196,30,58,0.3);
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #c41e3a;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 50px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   RESPONSIVE - TABLET (max-width: 768px)
   ========================================================================== */

@media (max-width: 768px) {

    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
    }

    /* LOGO: only max-height shrinks it, width:auto keeps proportions */
    .site-logo img,
    .custom-logo-link img,
    img.custom-logo {
        max-height: 55px !important;
        height: auto !important;
        width: auto !important;
    }

    .header-main {
        padding: 10px 0 !important;
    }

    .header-container {
        padding: 0 15px !important;
    }

    .site-title {
        font-size: 26px !important;
    }

    .nav-menu a {
        padding: 10px 14px !important;
        font-size: 13px !important;
    }

    .newspaper-container {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100vw !important;
        overflow: hidden !important;
    }

    .viewer-controls-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 10px !important;
        gap: 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .newspaper-title-display {
        order: 1 !important;
        flex: unset !important;
        width: 100% !important;
        text-align: center !important;
    }

    .newspaper-title-display h2 {
        font-size: 0.82em !important;
        line-height: 1.5 !important;
        word-break: break-word !important;
        color: #ffffff !important;
    }

    .date-selector {
        order: 2 !important;
        width: 100% !important;
        justify-content: center !important;
        padding: 6px 10px !important;
        box-sizing: border-box !important;
    }

    .date-selector input[type="date"] {
        width: 100% !important;
        font-size: 13px !important;
    }

    .viewer-tab-buttons {
        order: 3 !important;
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
    }

    .tab-btn {
        flex: 1 !important;
        justify-content: center !important;
        padding: 8px 10px !important;
        font-size: 12px !important;
    }

    .page-thumbnails-bar {
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 10px 8px !important;
        gap: 8px !important;
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .page-thumb-item {
        width: 72px !important;
        min-width: 72px !important;
        flex-shrink: 0 !important;
    }

    .page-thumb-item img {
        height: 100px !important;
        width: 100% !important;
    }

    .page-thumb-label {
        font-size: 10px !important;
        padding: 3px 5px !important;
        white-space: nowrap !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        bottom: 3px !important;
    }

    /* Core fix: block layout so image fills container width */
    .newspaper-display-area {
        display: block !important;
        padding: 0px !important;
        min-height: unset !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        position: relative !important;
    }

    .newspaper-image-wrapper {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        position: relative !important;
        overflow: hidden !important;
    }

    .newspaper-main-image {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2) !important;
    }

    /* Arrows move to natural flow bar above image */
    .page-navigation {
        position: relative !important;
        top: unset !important;
        left: unset !important;
        right: unset !important;
        transform: none !important;
        display: flex !important;
        justify-content: space-between !important;
        padding: 8px 5px !important;
        pointer-events: auto !important;
        background: #d8d8d8 !important;
        margin-bottom: 8px !important;
    }

    .nav-arrow {
        width: 38px !important;
        height: 38px !important;
        font-size: 15px !important;
        pointer-events: auto !important;
    }

    .magnifier-glass {
        display: none !important;
    }

    .archive-calendar {
        margin: 10px auto !important;
        padding: 10px !important;
    }

    .archive-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }

    .archive-thumb {
        height: 180px !important;
    }

    .archive-info {
        padding: 10px !important;
    }

    .archive-date {
        font-size: 0.95em !important;
    }

    .site-footer {
        margin-top: 20px !important;
        padding: 15px !important;
        font-size: 13px !important;
    }
}

/* ==========================================================================
   RESPONSIVE - SMALL PHONES (max-width: 480px)
   ========================================================================== */

@media (max-width: 480px) {

    .site-logo img,
    .custom-logo-link img,
    img.custom-logo {
        max-height: 42px !important;
        height: auto !important;
        width: auto !important;
    }

    .header-main {
        padding: 8px 0 !important;
    }

    .newspaper-title-display h2 {
        font-size: 0.72em !important;
    }

    .tab-btn {
        font-size: 11px !important;
        padding: 7px 6px !important;
        gap: 4px !important;
    }

    .page-thumb-item {
        width: 60px !important;
        min-width: 60px !important;
    }

    .page-thumb-item img {
        height: 85px !important;
    }

    .archive-grid {
        grid-template-columns: 1fr !important;
    }

    .nav-arrow {
        width: 32px !important;
        height: 32px !important;
        font-size: 13px !important;
    }
}