/* 1. GLOBAL FIX: Prevents borders/padding from spilling over */
* {
    box-sizing: border-box;
}

body {
    font-family: sans-serif;
    margin: 0;
    padding: 15px;
    background-color: #fff;
    display: flex;
    justify-content: center;
    /* FIX: Ensure body takes full height so padding works */
    min-height: 100vh; 
}

/* Main Container */
.viewer-container {
    width: 100%;
    max-width: 600px; /* Limits width on Desktop */
    display: flex;
    flex-direction: column;
    position: relative; /* Helps contain children */
}

/* --- AD SLOT NUCLEAR FIX --- */
#ad-header-slot {
    background-color: #f4f4f4;
    border: 1px solid #e0e0e0;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 90px;
    
    /* FORCE content to stay inside */
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important; 
}

/* TARGET EVERYTHING inside the ad slot (img, iframe, div) */
#ad-header-slot * {
    max-width: 100% !important;
    height: auto !important;
}

/* Security Warning */
.security-warning {
    background-color: #ffe6e6;
    color: #cc0000;
    padding: 10px;
    border-radius: 4px;
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 15px;
    border: 1px solid #ffcccc;
    text-align: center;
}

/* Anchor Text */
.anchor-text-container {
    font-size: 1.0em;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}
.anchor-text-container strong {
    display: block;
    margin-bottom: 5px;
    color: #0000AF;
}
.anchor-text-container blockquote {
    margin: 0;
    padding: 10px 15px;
    font-style: italic;
    font-family: "Georgia", serif;
    background-color: #eef2f5;
    border-left: 4px solid #0000AF;
    border-radius: 4px;
    word-wrap: break-word;
    font-size: 1.1em;
}
.anchor-text-container blockquote::before {
    content: "“";
    font-size: 1.5em;
    line-height: 0.1em;
    margin-right: 0.25em;
    vertical-align: -0.4em;
    color: #0000AF;
}
.anchor-text-container blockquote::after {
    content: "”";
    font-size: 1.5em;
    line-height: 0.1em;
    margin-left: 0.1em;
    vertical-align: -0.45em;
    color: #0000AF;
}

/* Author Name */
.annotation-author {
    font-size: 1.0em;
    font-weight: bold;
    color: #555;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

/* Content Box */
.annotation-content {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    padding: 15px;
    margin-bottom: 15px;
    min-height: 100px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    resize: both;
}

/* --- NAVIGATION ROW (Prev / 1 of 1 / Next) --- */
.navigation {
    display: flex;
    flex-direction: row; 
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    width: 100%;
    gap: 10px;
}

.navigation button {
    flex: 1; 
    padding: 10px;
    min-width: 80px; 
}

#nav-counter {
    margin: 0 10px;
    font-weight: bold;
    white-space: nowrap; 
    flex-shrink: 0; 
}

/* Action Buttons Row */
.actions {
    display: flex;
    justify-content: space-between;
    align-items: stretch; /* Forces all buttons to stretch to the same height */
    flex-wrap: wrap; /* Allows wrapping if the screen gets too narrow */
    margin-bottom: 20px;
    gap: 8px; /* Slightly tighter gap to fit them all nicely */
}

/* Force every action button to be the exact same size and height */
.actions button {
    flex: 1; /* Makes them share the width equally */
    min-width: 85px; /* Prevents them from getting too squished */
    height: 40px; /* Standardizes the height */
    padding: 0 10px;
    font-size: 0.9em;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0; /* Removes any weird default margins */
}

/* Footer Info Row */
.footer-info {
    display: flex;
    justify-content: space-between; /* Pushes Close button to the right */
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

/* Groups the credits text and the buy button together on the left */
.credits-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

#credits-display {
    font-size: 0.95em;
    color: #333;
    font-weight: 600;
}

.buy-credits-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px; 
    padding: 0 20px; /* Added a bit more padding so the bigger text breathes */
    background-color: #0000AF;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 1.0em; /* INCREASED from 0.85em to 1.0em */
    font-weight: bold;
    transition: background-color 0.2s;
    box-sizing: border-box;
}
.buy-credits-btn:hover {
    background-color: #000080;
}

/* General Button Styles */
button {
    border: 1px solid #ccc;
    background-color: #f0f0f0;
    cursor: pointer;
    border-radius: 4px;
    box-sizing: border-box;
}
button:hover {
    background-color: #e0e0e0;
}
button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Specific Button Colors */
#addAnnotationBtn { background-color: #0000AF; color: white; border-color: #000080; }
#addAnnotationBtn:hover { background-color: #000080; }
#forwardBtn { background-color: #d4edda; border-color: #c3e6cb; }
#rejectBtn { background-color: #fff3cd; border-color: #ffeeba; }
#reportBtn { background-color: #f8d7da; border-color: #f5c6cb; }
#deleteBtn { background-color: #8b0000; color: white; border-color: #800000; }
#deleteBtn:hover { background-color: #a00000; }

/* The New Red Close Button */
.close-btn { 
    background-color: #E90014; /* Your requested deeper red */
    color: white; 
    border-color: #D10014; 
    height: 40px;
    padding: 0 20px;
    font-weight: bold;
}
.close-btn:hover { 
    background-color: #D10014; /* Your requested hover red */
}

/* --- MOBILE & TABLET OPTIMIZATIONS --- */
@media screen and (max-width: 600px) {
    body {
        padding: 10px !important;
        padding-top: 2vh !important;
        
        /* FIX: Force 100px padding at the bottom of the BODY. 
           This is the most reliable way to clear iPhone toolbars. */
        padding-bottom: 100px !important;
        
        width: 100% !important;
        display: block !important; 
    }

    .viewer-container {
        width: 100% !important;
        max-width: none !important;
        /* Remove container padding since we moved it to body */
        padding-bottom: 0 !important; 
    }

    .actions {
        flex-direction: column;
        gap: 10px;
    }

    .actions button {
        width: 100%;
        padding: 15px; 
        font-size: 16px;
    }
    
    .navigation {
        flex-direction: row; 
    }
}