/*
 * Mega Tools - Refactored Global Stylesheet v8.0 (No Background - Responsive Fix)
 * - Description: Consolidated styles for all tools.
 * - Change: REMOVED all container backgrounds, borders, and shadows to blend with theme.
 * - Change: Set text to 'inherit' to match parent theme.
 * - Change: Set Primary buttons (.mt-btn-primary) to GREEN.
 * - Change: Kept Default buttons (.mt-btn) BLUE.
 * - Change: Kept Stop button red.
 * - Change: Kept QR code output area white for scannability.
 * - Change: Set border-radius to 20px for a rounder look.
 * - FIX: Re-added responsive media queries that were accidentally deleted.
 */

/* ========================================================================
   1. CSS Variables (No Background Theme)
   ======================================================================== */

.mt-tool-container {
    /* Backgrounds (NONE) */
    --mt-bg-primary: transparent;
    --mt-bg-secondary: transparent;
    --mt-bg-tertiary: transparent;

    /* Text (Inherit from theme) */
    --mt-text-primary: inherit;
    --mt-text-secondary: inherit;
    --mt-text-muted: inherit;
    --mt-text-inverted: #ffffff; /* White text for colored buttons */

    /* Borders & Shadows (Subtle border for inputs, NO shadow) */
    --mt-border-color: #3182ce; /* Border for default buttons (BLUE) */
    --mt-input-border-color: #4a5568; /* Kept subtle border for inputs */
    --mt-shadow-color: none;
    --mt-focus-ring-color: rgba(76, 175, 80, 0.5); /* CHANGED: Focus ring to GREEN */

    /* Buttons */
    --mt-btn-primary-bg: #4CAF50; /* CHANGED: Primary/Start button to GREEN */
    --mt-btn-primary-hover-bg: #45a049; /* CHANGED: Darker GREEN */
    
    --mt-btn-stop-bg: #e53e3e;
    --mt-btn-stop-hover-bg: #c53030;
    
    /* --- Default buttons are BLUE --- */
    --mt-btn-default-bg: #3182ce; /* CHANGED: Set default button to BLUE */
    --mt-btn-default-text: #ffffff; /* CHANGED: Set default text to WHITE */
    --mt-btn-default-hover-bg: #2b6cb0; /* CHANGED: Set default hover to DARKER BLUE */
    /* --- END --- */

    /* Notifications (These MUST have a background to be readable) */
    --mt-notif-success-bg: #2f855a;
    --mt-notif-success-text: #f0fff4;
    --mt-notif-success-border: #38a169;
    --mt-notif-error-bg: #c53030;
    --mt-notif-error-text: #fff5f5;
    --mt-notif-error-border: #e53e3e;

    /* Layout */
    --mt-gap: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

/* ========================================================================
   2. REMOVED Dark Mode Override
   ======================================================================== */

/* Dark mode block entirely removed */

/* ========================================================================
   3. Base Container & Typography
   ======================================================================== */

.mt-tool-container {
    background-color: var(--mt-bg-primary); /* transparent */
    border: none; /* REMOVED */
    color: var(--mt-text-secondary); /* inherit */
    border-radius: 0; /* REMOVED */
    padding: 18px;
    max-width: 1020px;
    margin: 28px auto;
    box-shadow: none; /* REMOVED */
    box-sizing: border-box;
}
.mt-tool-container *,
.mt-tool-container *::before,
.mt-tool-container *::after {
    box-sizing: inherit;
}

.mt-tool-container h1,
.mt-tool-container h3 {
    margin: 0 0 12px;
    font-size: 20px;
    color: var(--mt-text-primary); /* inherit */
}
.mt-tool-container .muted {
    color: var(--mt-text-muted); /* inherit */
    font-size: 14px;
    line-height: 1.6;
    margin-top: 0;
}
.mt-tool-container label {
    display: block;
    font-size: 13px;
    color: var(--mt-text-secondary); /* inherit */
    margin-bottom: 6px;
    font-weight: 600;
}

/* ========================================================================
   4. Form Elements (Inputs, Select, Textarea, Buttons)
   ======================================================================== */

.mt-tool-container input,
.mt-tool-container select,
.mt-tool-container .mt-textarea {
    width: 100%;
    padding: 10px;
    border-radius: 20px; /* Rounded */
    border: 1px solid var(--mt-input-border-color); /* subtle border */
    background: var(--mt-bg-primary); /* transparent */
    color: var(--mt-text-primary); /* inherit */
    font-size: 14px;
    transition: all .2s;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
}
.mt-tool-container .mt-textarea {
    min-height: 150px;
    resize: vertical;
}

.mt-tool-container input:focus,
.mt-tool-container select:focus,
.mt-tool-container .mt-textarea:focus {
    outline: none;
    border-color: var(--mt-btn-primary-bg); /* Now Green */
    box-shadow: 0 0 0 2px var(--mt-focus-ring-color); /* Now Green */
}
.mt-tool-container input:disabled,
.mt-tool-container select:disabled,
.mt-tool-container .mt-textarea:disabled {
    background: var(--mt-bg-secondary); /* transparent */
    cursor: not-allowed;
    opacity: 0.7;
}

/* --- Buttons --- */

.mt-tool-container .mt-btn {
    width: auto;
    background: var(--mt-btn-default-bg); /* NOW BLUE */
    color: var(--mt-btn-default-text); /* NOW WHITE */
    border: 1px solid var(--mt-border-color); /* NOW BLUE BORDER */
    padding: 10px 14px;
    border-radius: 20px; /* Rounded */
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    transition: background-color .2s, border-color .2s, color .2s;
    text-align: center;
    display: inline-block;
}
.mt-tool-container .mt-btn:hover {
    background: var(--mt-btn-default-hover-bg); /* NOW DARKER BLUE */
}

.mt-tool-container .mt-btn-primary {
    background-color: var(--mt-btn-primary-bg); /* GREEN */
    color: var(--mt-text-inverted); /* white */
    border-color: var(--mt-btn-primary-bg); /* GREEN border */
    width: 100%;
    border-radius: 20px; /* Rounded */
}
.mt-tool-container .mt-btn-primary:hover {
    background-color: var(--mt-btn-primary-hover-bg); /* DARKER GREEN */
}
.mt-tool-container .mt-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mt-tool-container .mt-btn.stop {
    background: var(--mt-btn-stop-bg); /* red */
    border-color: var(--mt-btn-stop-bg);
    color: var(--mt-text-inverted); /* white */
    border-radius: 20px; /* Rounded */
}
.mt-tool-container .mt-btn.stop:hover {
    background: var(--mt-btn-stop-hover-bg);
}

.mt-tool-container .mt-btn-fileupload {
    cursor: pointer;
    width: 100%;
}
.mt-tool-container .mt-btn-fileupload input[type="file"] {
    display: none; /* Hide the original file input */
}

/* ========================================================================
   5. Layout (Grid, Flex, Button Groups)
   ======================================================================== */

/* --- Base Grid & Flex --- */
.mt-tool-container .mt-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: var(--mt-gap);
}
.mt-tool-container .mt-grid-gap {
    margin-top: 10px;
}
.mt-tool-container .mt-grid-span-2 {
    grid-column: span 2 !important;
}
.mt-tool-container .mt-grid-span-3 {
    grid-column: span 3 !important;
}
.mt-tool-container .mt-grid-span-4 {
    grid-column: span 4 !important;
}
.mt-tool-container .mt-align-end {
    display: flex !important;
    align-items: flex-end;
}
.mt-tool-container .mt-actions {
    display: flex !important;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 15px;
    align-items: center;
}
.mt-tool-container .mt-flex-grow {
    flex: 1;
}

/* --- Button Groups --- */
.mt-tool-container .mt-button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--mt-gap);
    margin-top: var(--mt-gap);
}
.mt-tool-container .mt-button-group-3 {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: var(--mt-gap);
    margin-top: 10px;
}
.mt-tool-container .mt-button-group-3 .mt-btn {
    width: 100%;
}
.mt-tool-container .mt-button-group-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--mt-gap);
    margin-top: var(--mt-gap);
}
.mt-tool-container .mt-button-group-4 .mt-btn {
    width: 100%;
}
.mt-tool-container .mt-button-group-5 {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: var(--mt-gap);
    margin-top: 10px;
}
.mt-tool-container .mt-button-group-5 .mt-btn {
    width: 100%;
}

/* ========================================================================
   6. Components (Notifications, Status, Results)
   ======================================================================== */

.mt-tool-container .mt-status-box {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 20px; /* Rounded */
    background: var(--mt-bg-secondary); /* transparent */
    border: 1px solid var(--mt-input-border-color); /* subtle border */
    color: var(--mt-text-secondary); /* inherit */
}
.mt-tool-container .mt-stats {
    margin-top: 12px;
    color: var(--mt-text-muted); /* inherit */
    font-size: 13px;
}
.mt-tool-container .mt-result-list {
    background: var(--mt-bg-secondary); /* transparent */
    border-radius: 20px; /* Rounded */
    padding: 12px;
    margin-top: 12px;
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--mt-input-border-color); /* subtle border */
}
.mt-tool-container .kw-item {
    padding: 6px 8px;
    border-radius: 16px; /* Rounded */
    margin-bottom: 6px;
    background: var(--mt-bg-primary); /* transparent */
    border-bottom: 1px solid var(--mt-input-border-color); /* subtle border */
    font-size: 14px;
    color: var(--mt-text-primary); /* inherit */
}

/* Notifications keep their background for visibility */
.mt-tool-container .mt-notification {
    padding: 10px 15px;
    margin-top: 15px;
    border-radius: 20px; /* Rounded */
    font-size: 14px;
    background-color: var(--mt-notif-success-bg);
    color: var(--mt-notif-success-text);
    border: 1px solid var(--mt-notif-success-border);
}
.mt-tool-container .mt-notification.error {
    background-color: var(--mt-notif-error-bg);
    color: var(--mt-notif-error-text);
    border-color: var(--mt-notif-error-border);
}

/* ========================================================================
   7. Tool-Specific Styles
   ======================================================================== */

/* --- Text Counter Stats Grid --- */
.mt-stats-grid {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: var(--mt-gap);
    margin-top: 10px;
}
.mt-stat-box {
    background: var(--mt-bg-secondary); /* transparent */
    border: 1px solid var(--mt-input-border-color); /* subtle border */
    border-radius: 20px; /* Rounded */
    padding: 14px;
    text-align: center;
    box-shadow: var(--mt-shadow-color); /* none */
}
.mt-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--mt-text-primary); /* inherit */
    line-height: 1.2;
}
.mt-stat-label {
    display: block;
    font-size: 13px;
    color: var(--mt-text-muted); /* inherit */
    margin-top: 4px;
}

/* --- QR Code Generator Card --- */
.mt-qr-card {
    background: var(--mt-bg-primary); /* transparent */
    border: none; /* REMOVED */
    box-shadow: var(--mt-shadow-color); /* none */
    overflow: hidden;
    border-radius: 0;
}
.mt-qr-card-header {
    padding: var(--mt-gap);
    border-bottom: 1px solid var(--mt-input-border-color); /* subtle border */
}
.mt-qr-card-header h3 {
    margin-top: 0;
    margin-bottom: 8px;
}
.mt-qr-card-header p.muted {
    margin-bottom: 0;
    font-size: 14px;
}
.mt-qr-card .mt-grid {
    padding: var(--mt-gap);
    align-items: start;
}
.mt-qr-output-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: var(--mt-gap);
    margin-top: 0;
}
/* QR Code *must* have a white background to be scannable */
.mt-qr-output {
    padding: 12px;
    background: #ffffff; /* KEPT WHITE BACKGROUND */
    border: 1px solid var(--mt-input-border-color);
    border-radius: 20px; /* Rounded */
    line-height: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Subtle shadow just for QR */
    width: 282px;
    height: 282px;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.mt-qr-output canvas,
.mt-qr-output img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}
.mt-qr-placeholder {
    color: var(--mt-text-muted); /* inherit */
    font-size: 14px;
    text-align: center;
    line-height: 1.5;
    padding: 20px;
    background-color: var(--mt-bg-secondary); /* transparent */
    width: 100%;
    height: 100%;
    border: 1px dashed var(--mt-input-border-color);
    border-radius: 20px; /* Rounded */
}


/* ========================================================================
   8. Responsive Media Queries (FIXED)
   ======================================================================== */

@media(max-width: 768px) {
    .mt-tool-container .mt-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    
    .mt-tool-container .mt-button-group-5 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    .mt-tool-container .mt-button-group-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .mt-stats-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .mt-qr-card .mt-grid-span-2 {
        grid-column: span 4 !important; /* Stack columns */
    }
    .mt-qr-output-column {
        flex-direction: column-reverse;
    }
    .mt-qr-output {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }
}

@media(max-width: 480px) {
    .mt-tool-container .mt-grid {
        grid-template-columns: 1fr !important;
    }
    .mt-tool-container .mt-grid .mt-grid-span-2,
    .mt-tool-container .mt-grid .mt-grid-span-3,
    .mt-tool-container .mt-grid .mt-grid-span-4 {
        grid-column: span 1 !important;
    }
    
    .mt-tool-container .mt-button-group,
    .mt-tool-container .mt-button-group-3,
    .mt-tool-container .mt-button-group-4,
    .mt-tool-container .mt-button-group-5 {
        grid-template-columns: 1fr !important;
    }
    
    .mt-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

