/* =========================================
   GLOBAL VARIABLES & RESET
   ========================================= */
:root {
    --primary: #1095c1;
    --primary-hover: #0a7ca1;
    --card-bg: #ffffff;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --shadow: 0 10px 20px rgba(0,0,0,0.05);
}

/* DARK MODE OVERRIDES */
@media (prefers-color-scheme: dark) {
    :root {
        --card-bg: #1e252b;
        --bg-gradient: linear-gradient(135deg, #11191f 0%, #18222a 100%);
        --shadow: 0 10px 20px rgba(0,0,0,0.3);
    }
}

body {
    background: var(--bg-gradient);
    min-height: 100vh;
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
}

/* =========================================
   HERO SECTION & SEARCH
   ========================================= */
.hero {
    text-align: center;
    padding: 4rem 1rem;
    margin-bottom: 2rem;
}
.hero h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #1095c1, #5d48bf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}
.hero p {
    font-size: 1.2rem;
    color: #666;
    max-width: 600px;
    margin: 0 auto;
}

/* SEARCH BAR */
.search-container {
    max-width: 500px;
    margin: 2rem auto;
    position: relative;
}
.search-container input {
    border-radius: 50px !important;
    padding-left: 2.5rem !important;
    border: 2px solid var(--primary);
    box-shadow: 0 4px 10px rgba(16, 149, 193, 0.2);
    background: white;
    color: #333;
    width: 100%;
    padding-top: 10px;
    padding-bottom: 10px;
    box-sizing: border-box; /* Fix width issues */
}
.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary);
}

/* =========================================
   SECTION STYLING (THE COLORED BOXES)
   ========================================= */
.tool-section {
    padding: 50px 30px;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    margin: 40px 0;
    color: #fff;
    position: relative;
    overflow: visible !important;
}

.tool-section .section-title {
    color: white !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 10px;
    display: block;
    font-size: 1.8rem;
}

hr { display: none; }

/* --- UNIQUE COLOR THEMES PER SECTION --- */
#sec-section { background: linear-gradient(145deg, #0f172a 0%, #334155 100%); }
#pdf-section { background: linear-gradient(145deg, #7f1d1d 0%, #991b1b 100%); }
#img-section { background: linear-gradient(145deg, #312e81 0%, #4338ca 100%); }
#text-section { background: linear-gradient(145deg, #064e3b 0%, #065f46 100%); }

/* =========================================
   GRID SYSTEM
   ========================================= */
.grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) !important; 
    gap: 20px !important;
    width: 100% !important;
    grid-template-rows: auto !important;
    align-items: stretch !important;
}

/* =========================================
   PREMIUM "DARK GLASS" CARD STYLING
   ========================================= */
.tool-section .tool-card {
    background: rgba(30, 41, 59, 0.6) !important; 
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 16px !important;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 25px !important;
    margin: 0 !important;
    height: 100% !important;
    color: #fff !important;
    text-align: left; 
    transition: all 0.3s ease;
}

.tool-section .tool-card:hover {
    transform: translateY(-7px) !important;
    background: rgba(30, 41, 59, 0.8) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4) !important;
}

.tool-card .tool-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-bottom: 20px;
    color: #fff;
    font-size: 1.5rem !important;
    transition: all 0.3s ease;
}

.tool-section .tool-card:hover .tool-icon {
    background: var(--primary); 
    color: white;
    box-shadow: 0 0 15px var(--primary);
}

.tool-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: #fff !important;
}

.tool-card p {
    font-size: 0.9rem;
    color: #cbd5e1 !important;
    line-height: 1.5;
    margin-bottom: 20px;
    flex-grow: 1; 
}

.tool-card footer { margin-top: auto; }

.tool-card .tool-btn {
    display: block;
    width: 100%;
    background: var(--primary); 
    border: none;
    color: white !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    padding: 12px 0;
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.tool-card .tool-btn:hover {
    background: white;
    color: var(--primary) !important; 
    border: none;
}

/* =========================================
   NAVIGATION & FOOTER
   ========================================= */
.tool-nav h5 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #888;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
    letter-spacing: 1px;
}
.tool-nav ul { list-style: none; padding: 0; margin: 0; }
.tool-nav li { margin-bottom: 0.2rem; }
.tool-nav a {
    display: block;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s, padding-left 0.2s;
    border: 1px solid transparent;
}
.tool-nav a:hover {
    background: #f0f8ff;
    padding-left: 1rem;
    border-color: #d1e9ff;
}
.tool-nav i { margin-right: 8px; width: 20px; text-align: center; color: #aaa; }
.tool-nav a:hover i { color: var(--primary); }

footer {
    text-align: center;
    padding: 3rem 0;
    margin-top: 3rem;
    border-top: 1px solid rgba(0,0,0,0.1);
    color: #666;
}

/* =========================================
   BACK TO TOP BUTTON
   ========================================= */
#backToTop {
    opacity: 0;
    visibility: hidden;
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #5d48bf);
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease-in-out;
    transform: translateY(20px);
}
#backToTop.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
#backToTop:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(16, 149, 193, 0.4);
    background: linear-gradient(135deg, #5d48bf, var(--primary));
}

@media (max-width: 768px) {
    #backToTop {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 1rem;
        opacity: 0.9; 
    }
}

/* =========================================
   COMMAND CENTER MODAL (FINAL FIX)
   ========================================= */
.tool-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5vh;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tool-modal-overlay.active { 
    display: flex; 
    opacity: 1; 
}

/* Modal Content Box */
.tool-modal-content {
    background: #1e293b; 
    width: 100%;
    max-width: 100vh;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 25px -12px rgba(0, 0, 0, 0.5);
    padding: 20px;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    max-height: 85vh;
    overflow-y: auto;
    color: #f1f5f9;
    box-sizing: border-box; /* IMPORTANT */
}

.tool-modal-overlay.active .tool-modal-content {
    transform: translateY(0);
}

/* 1. Header: Keeps text safe on the left */
.tool-modal-header {
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 20px;
    width: 100%;
    position: relative; /* Crucial for alignment */
    /* Removed Flexbox to allow absolute corner positioning */
}

.tool-modal-header h2 {
    margin: 0;
    color: var(--primary);
    font-size: 1.8rem;
    text-align: left;
    
    /* SAFETY GUARD: Prevents text from hitting the button */
    padding-right: 60px; 
    width: 100%;
    box-sizing: border-box;
}

/* 2. Close Button: Sticks to the Top-Right Corner */
.close-modal-btn {
    position: absolute; /* Ignore padding, stick to edge */
    top: -10px;         /* Pull it up into the corner */
    right: -10px;       /* Pull it right to the edge */
    
    width: 40px;        /* Fixed touch target size */
    height: 40px;
    
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
    
    /* Centering the X inside the button box */
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal-btn:hover {
    color: #ef4444; 
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 40px;
}

.category-column h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #94a3b8;
    margin-bottom: 20px;
    border-left: 3px solid var(--primary);
    padding-left: 12px;
}

.tool-link-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: #e2e8f0;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-bottom: 5px;
}

.tool-link-item:hover {
    background: rgba(16, 149, 193, 0.2); 
    color: var(--primary);
    transform: translateX(5px);
}

.tool-link-item i {
    width: 24px;
    text-align: center;
    color: var(--primary);
    opacity: 0.8;
}
/* --- AD INTERSTITIAL MODAL --- */
.ad-wait-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.95); /* Black background */
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
}

.ad-wait-content {
    background: #1e293b;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #334155;
    max-width: 600px;
    width: 90%;
    position: relative;
}

.ad-timer-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 5px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    margin: 0 auto 20px auto;
    color: var(--primary);
}

.ad-placeholder-box {
    background: #0f172a;
    border: 2px dashed #334155;
    min-height: 250px;
    margin: 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.skip-btn {
    background: #64748b;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: not-allowed;
    opacity: 0.5;
    transition: all 0.3s;
}

.skip-btn.active {
    background: var(--primary);
    cursor: pointer;
    opacity: 1;
}