/**
 * OptiCache Admin Styles
 */

/* ============================================
   HIDE WORDPRESS DEFAULT NOTICES ON OUR PAGE
   ============================================ */

.toplevel_page_opticache .wrap > .notice:not(#opticache-toast),
.toplevel_page_opticache .wrap > .updated,
.toplevel_page_opticache .wrap > .error {
    display: none !important;
}

/* ============================================
   REMOVE MENU SEPARATOR
   ============================================ */

#adminmenu li#toplevel_page_opticache {
    border-bottom: none;
}

#adminmenu li#toplevel_page_opticache + li.wp-menu-separator {
    display: none;
}

/* ============================================
   MAIN SETTINGS WRAPPER
   ============================================ */

.opticache-settings-wrap {
    margin: 30px 30px 0 30px;
    padding: 22px 30px 0px 30px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    background-image: linear-gradient(178deg, rgb(255, 255, 255) 0%, rgb(247, 247, 247) 90%, rgb(235, 235, 235) 100%);
    overflow: hidden;
    max-width: 902px;
}

.opticache-settings-wrap h1 {
    color: #23282d;
    font-size: 24px;
    margin-bottom: 10px;
    margin-top: -10px;
}

.opticache-header-stats {
    font-size: 13px;
    font-weight: normal;
    color: #50575e;
    display: flex;
    align-items: center;
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 4px;
}

.opticache-header-stats .dashicons {
    margin-right: 4px;
}

/* ============================================
   TAB NAVIGATION
   ============================================ */

.opticache-settings-wrap .nav-tab-wrapper {
    border-bottom: 1px solid #ddd;
    margin-bottom: 25px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 0;
}

.opticache-settings-wrap .nav-tab {
    padding: 7px 10px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-bottom: none;
    margin-right: 2px;
    text-decoration: none;
    color: #555;
    border-radius: 4px 4px 0 0;
    transition: all 0.3s ease;
}

.opticache-settings-wrap .nav-tab:hover {
    background: #e8e8e8;
}

.opticache-settings-wrap .nav-tab-active {
    background: #fff;
    border-bottom: 1px solid #fff;
    color: #0073aa;
    margin-bottom: -1px;
}

/* ============================================
   FORM SECTIONS
   ============================================ */

.opticache-settings-form .form-group {
    margin-bottom: 0;
}

.opticache-settings-form h3 {
    font-size: 18px;
    color: #23282d;
    margin: 20px 0 10px;
    margin-top: 20px;
    padding-bottom: 8px;
    border-bottom: 0;
}

.opticache-tab-section h3:first-of-type {
    margin-top: 25px;
}

.opticache-settings-form h3.opticache-section-divider {
    border-top: 1px solid #c3c4c7;
    padding-top: 20px;
    margin-top: 12px;
}

/* Tab Sections */
.opticache-tab-section {
    display: none;
}

.opticache-tab-section.active {
    display: block;
}

/* ============================================
   TABLE LAYOUT - Product Code Style
   60% width, 15px left margin, 30px td padding
   ============================================ */

.opticache-settings-form .opticache-table {
    width: 100%;
    max-width: 765px;
    margin: 0;
    margin-left: 15px;
    border-collapse: collapse;
}

.opticache-settings-form .opticache-table th,
.opticache-settings-form .opticache-table td {
    padding-top: 8px;
    padding-bottom: 8px;
    vertical-align: top;
}

.opticache-settings-form .opticache-table tr {
    border-bottom: none;
}

.opticache-settings-form .opticache-table th {
    width: 180px;
    text-align: left;
    padding-right: 10px;
}

.opticache-settings-form .opticache-table th label {
    font-weight: 600;
    color: #3c434a;
}

.opticache-settings-form .opticache-table td {
    padding-left: 20px;
}

/* ============================================
   TOGGLE SWITCH STYLING
   ============================================ */

/* Position checkbox over the toggle track so it's clickable */
.opticache-settings-form .opticache-table .checkinput-box {
    position: relative;
    width: 56px;
    height: 24px;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    flex-shrink: 0;
}

/* Toggle track - shown via ::before on the description */
.opticache-settings-form .opticache-table .checkinput-description {
    position: relative;
    margin: 0;
    margin-left: -56px;
    padding-left: 66px;
    color: #3c434a;
    font-size: 14px;
    line-height: 24px;
    font-style: normal;
    font-weight: normal;
    cursor: pointer;
    display: inline-block;
}

/* Toggle track background */
.opticache-settings-form .opticache-table .checkinput-description::before {
    content: 'OFF';
    position: absolute;
    left: 0;
    top: 0;
    width: 56px;
    height: 24px;
    background: #95a5a6;
    border-radius: 12px;
    transition: background 0.25s ease;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    text-align: right;
    padding-right: 8px;
    line-height: 24px;
    box-sizing: border-box;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.18);
}

/* Toggle slider circle */
.opticache-settings-form .opticache-table .checkinput-description::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    background: #3d3d3da3;
    border-radius: 50%;
    transition: left 0.25s ease, background 0.25s ease;
}

/* Checked state - track */
.opticache-settings-form .opticache-table .checkinput-box:checked + .checkinput-description::before {
    content: 'ON';
    background: #78bd8f;
    text-align: left;
    padding-left: 10px;
    padding-right: 0;
}

/* Checked state - slider */
.opticache-settings-form .opticache-table .checkinput-box:checked + .checkinput-description::after {
    left: 35px;
    background: #0a7934;
}

/* Focus state for accessibility - only when checked */
.opticache-settings-form .opticache-table .checkinput-box:focus:checked + .checkinput-description::before {
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.18), 0 0 0 2px rgba(46, 204, 113, 0.3);
}

/* Tighten row spacing for toggle rows */
.opticache-settings-form .opticache-table tr:has(.checkinput-box) td {
    padding-top: 6px;
    padding-bottom: 6px;
}

/* ============================================
   SECTION HEADERS IN TABLE
   ============================================ */

.opticache-settings-form .opticache-table tr.opticache-section-header th {
    padding-top: 20px;
    padding-bottom: 5px;
}

.opticache-settings-form .opticache-table tr.opticache-section-header th h3 {
    margin: 0;
    padding: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1d2327;
}

/* ============================================
   INPUT FIELDS - Product Code Style
   ============================================ */

.opticache-settings-form .opticache-table select {
    min-width: 230px;
    max-width: 230px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
    background-color: #fff;
    color: #3c434a;
    font-size: 14px;
    line-height: 28px;
    vertical-align: middle;
}

.opticache-settings-form .opticache-table input[type="text"],
.opticache-settings-form .opticache-table input[type="email"],
.opticache-settings-form .opticache-table input[type="url"],
.opticache-settings-form .opticache-table input[type="number"],
.opticache-settings-form .opticache-table input[type="password"] {
    border: 1px solid #8c8f94;
    border-radius: 4px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
    background-color: #fff;
    color: #3c434a;
    padding: 0 8px;
    height: 30px;
    font-size: 14px;
    line-height: 28px;
}

.opticache-settings-form .opticache-table input[type="text"]:focus,
.opticache-settings-form .opticache-table input[type="email"]:focus,
.opticache-settings-form .opticache-table input[type="url"]:focus,
.opticache-settings-form .opticache-table input[type="number"]:focus,
.opticache-settings-form .opticache-table input[type="password"]:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}

.opticache-settings-form .opticache-table textarea {
    width: 100%;
    max-width: 100%;
    min-height: 100px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
    background-color: #fff;
    color: #3c434a;
    padding: 8px 10px;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.4;
    resize: vertical;
}

.opticache-settings-form .opticache-table select:focus,
.opticache-settings-form .opticache-table textarea:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}

/* Input wrap for inline tooltip */
.opticache-settings-form .opticache-input-wrap {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
}

.opticache-settings-form .opticache-input-wrap textarea {
    flex: 1 1 auto;
    width: 100%;
}

/* ============================================
   DESCRIPTION TEXT - NOT italic
   ============================================ */

.opticache-settings-form .opticache-table .description {
    color: #3c434a;
    font-size: 14px;
    margin-top: 4px;
    font-style: normal;
}

/* ============================================
   TOOLTIP STYLING - Product Code Style
   ============================================ */

.opticache-tooltip {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    margin-left: 4px;
}

.opticache-tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: rgba(0, 0, 0, 0.75);
    color: #fff;
    text-align: left;
    font-size: 12px;
    line-height: 1.4;
    border-radius: 4px;
    padding: 8px 10px;
    position: absolute;
    z-index: 9999;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}

.opticache-tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    margin-top: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent rgba(0, 0, 0, 0.75) transparent transparent;
}

.opticache-tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Tooltip positioned to the left (for elements near right edge) */
.opticache-tooltip.tooltip-left .tooltiptext {
    left: auto;
    right: 28px;
}

.opticache-tooltip.tooltip-left .tooltiptext::after {
    right: auto;
    left: 100%;
    border-color: transparent transparent transparent rgba(0, 0, 0, 0.75);
}

.opticache-tooltip .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    vertical-align: top;
    line-height: 1;
    cursor: help;
}

.opticache-tooltip .dashicons-editor-help:before {
    color: #72777c;
}

.opticache-tooltip:hover .dashicons-editor-help:before {
    color: #2271b1;
}

/* Tooltip inline with checkbox description */
.opticache-settings-form .opticache-table td .checkinput-description + .opticache-tooltip {
    vertical-align: middle;
    margin-left: 4px;
}

/* ============================================
   WARNING TEXT
   ============================================ */

.opticache-warning-text {
    color: #d63638;
    font-weight: normal;
}

/* ============================================
   SUBMIT BAR
   ============================================ */

.opticache-settings-form .submit {
    margin: 20px -30px 0 -30px;
    padding: 15px 20px;
    background: #f1f1f1;
    border-top: 1px solid #c3c4c7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    border-radius: 0 0 8px 8px;
}

.opticache-settings-form .submit .opticache-submit-buttons {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.opticache-settings-form .submit .opticache-submit-buttons .button-primary {
    margin: 0;
}

.opticache-settings-form .submit .opticache-donation-text {
    color: #3c434a;
    font-size: 13px;
    margin: 0;
}

.opticache-settings-form .submit .opticache-donation-text .button {
    margin-left: 5px;
}

/* ============================================
   STATS ROW
   ============================================ */

.opticache-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    margin-left: 15px;
}

.opticache-stat-box-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.opticache-stat-box {
    background: #fff;
    border: 1px solid #b9b9b9;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 16px 20px;
    min-width: 180px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.opticache-stat-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.opticache-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1d2327;
    line-height: 1.2;
}

.opticache-stat-label {
    font-size: 12px;
    color: #646970;
    margin-top: 4px;
}

/* ============================================
   QUICK ACTIONS
   ============================================ */

.opticache-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    margin-left: 15px;
}

/* ============================================
   .HTACCESS PREVIEW
   ============================================ */

.opticache-htaccess-preview {
    width: 100%;
    max-width: 765px;
    margin-left: 15px;
    background: #f6f7f7;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.5;
    max-height: 350px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-top: 10px;
}

.opticache-htaccess-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    margin-left: 15px;
}

/* ============================================
   SYSTEM INFO TABLE - 60% width
   ============================================ */

.opticache-system-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 735px;
    margin-left: 15px;
    margin-bottom: 20px;
    background: #fff;
    border: 1px solid #b9b9b9;
    border-radius: 4px;
    padding: 20px;
}

.opticache-system-info-col table {
    width: 100%;
    border-collapse: collapse;
}

.opticache-system-info-col th,
.opticache-system-info-col td {
    padding: 6px 0;
    text-align: left;
    border-bottom: 1px solid #f0f0f1;
    font-size: 13px;
}

.opticache-system-info-col th {
    color: #646970;
    font-weight: normal;
    width: 45%;
}

.opticache-system-info-col td {
    color: #1d2327;
}

.opticache-system-info-col tr:last-child th,
.opticache-system-info-col tr:last-child td {
    border-bottom: none;
}

/* Legacy single-column (keep for backward compatibility) */
.opticache-system-info {
    width: 100%;
    max-width: 750px;
    margin-left: 15px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

.opticache-system-info table {
    width: 100%;
    border-collapse: collapse;
}

.opticache-system-info th,
.opticache-system-info td {
    padding: 8px 0;
    text-align: left;
    border-bottom: 1px solid #f0f0f1;
    font-size: 13px;
}

.opticache-system-info th {
    color: #646970;
    font-weight: normal;
    width: 40%;
}

.opticache-system-info td {
    color: #1d2327;
}

.opticache-system-info tr:last-child th,
.opticache-system-info tr:last-child td {
    border-bottom: none;
}

/* ============================================
   STATUS SECTION
   ============================================ */

.opticache-status-section {
    margin-bottom: 20px;
    margin-left: 15px;
}

.opticache-status-section h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #1d2327;
}

/* ============================================
   CONFLICT ITEMS
   ============================================ */

.opticache-conflict-item {
    width: 100%;
    max-width: 750px;
    margin-left: 15px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
}

.opticache-conflict-name {
    font-weight: 600;
    color: #1d2327;
}

.opticache-conflict-details {
    color: #646970;
    font-size: 13px;
    margin-top: 3px;
}

.opticache-severity-badge {
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.opticache-severity-high {
    background: #facfd2;
    color: #8a1f1f;
}

.opticache-severity-medium {
    background: #fcf0c3;
    color: #6e5000;
}

.opticache-severity-low {
    background: #d7f0e5;
    color: #1e5631;
}

/* No conflicts message */
#tab-status > p {
    margin-left: 15px;
}

/* ============================================
   OPCACHE TAB STYLES
   ============================================ */

.opticache-opcache-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin: 0 0 25px 15px;
}

.opticache-opcache-widget {
    background: #fff;
    border: 1px solid #b9b9b9;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 15px;
    text-align: center;
    min-width: 130px;
}

.opticache-opcache-ring {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 10px;
}

.opticache-opcache-ring svg {
    display: block;
}

.opticache-opcache-ring-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 700;
    color: #1d2327;
}

.opticache-opcache-widget-label {
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
    margin-bottom: 4px;
}

.opticache-opcache-widget-detail {
    font-size: 12px;
    color: #646970;
}

.opticache-opcache-widget-info {
    min-width: 180px;
    text-align: left;
    padding: 15px 20px;
}

.opticache-opcache-widget-info table {
    width: 100%;
    border-collapse: collapse;
}

.opticache-opcache-widget-info td {
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f1;
}

.opticache-opcache-widget-info tr:last-child td {
    border-bottom: none;
}

.opticache-opcache-widget-info td:first-child {
    color: #646970;
    padding-right: 15px;
}

.opticache-opcache-widget-info td:last-child {
    color: #1d2327;
    text-align: right;
}

.opticache-opcache-actions {
    margin: 0 0 30px 15px;
}

.opticache-opcache-files-wrap {
    width: 100%;
    max-width: 765px;
    margin-left: 15px;
    margin-bottom: 20px;
}

.opticache-opcache-files-table {
    font-size: 13px;
}

.opticache-opcache-files-table th {
    background: #f6f7f7;
    font-weight: 600;
}

.opticache-opcache-files-table td,
.opticache-opcache-files-table th {
    padding: 8px 10px;
}

.opticache-opcache-files-table tbody tr:nth-child(odd) {
    background: #f9f9f9;
}

/* OPcache tab tooltip fix */
#tab-opcache .opticache-tooltip {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

#tab-opcache .opticache-tooltip .tooltiptext {
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    white-space: normal;
    z-index: 99999;
    position: absolute;
}

#tab-opcache .opticache-table,
#tab-opcache .opticache-table tr,
#tab-opcache .opticache-table td {
    overflow: visible;
}

/* ============================================
   SUCCESS MESSAGE
   ============================================ */

.opticache-success-msg {
    margin: 0 0 20px 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media only screen and (max-width: 800px) {
    .opticache-settings-wrap {
        margin: 20px 10px 0 10px;
        padding: 20px;
        padding-bottom: 0;
    }
    
    .opticache-settings-form .opticache-table {
        width: 100%;
        max-width: none;
        margin-left: 0;
    }
    
    .opticache-settings-form .opticache-table td {
        padding-left: 10px;
    }
    
    .opticache-settings-form .opticache-table textarea {
        max-width: none;
    }
    
    .opticache-stats-row,
    .opticache-quick-actions,
    .opticache-htaccess-preview,
    .opticache-htaccess-actions,
    .opticache-system-info,
    .opticache-system-info-grid,
    .opticache-status-section,
    .opticache-conflict-item,
    .opticache-opcache-stats,
    .opticache-opcache-actions,
    .opticache-opcache-files-wrap,
    #tab-status > p {
        margin-left: 0;
        width: 100%;
        max-width: none;
    }
    
    .opticache-system-info-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .opticache-settings-form .submit {
        margin: 20px -20px 0 -20px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .opticache-settings-form .submit .opticache-donation-text {
        margin-top: 10px;
    }
    
    .opticache-stats-row {
        flex-direction: column;
    }
    
    .opticache-stat-box-wrapper {
        width: 100%;
    }
    
    .opticache-stat-box {
        min-width: auto;
        width: 100%;
    }
    
    .opticache-tooltip .tooltiptext {
        left: 28px;
        top: 50%;
        transform: translateY(-50%);
        width: 180px;
    }
    
    .opticache-opcache-stats {
        flex-direction: column;
    }
    
    .opticache-opcache-widget {
        width: 100%;
        min-width: auto;
    }
}

@media screen and (max-width: 782px) {
    .opticache-settings-form .submit .opticache-submit-buttons a.button.button-secondary {
        padding: 0 10px;
        font-size: 13px;
        min-height: 30px;
        margin-bottom: 0;
        max-height: 30px;
        line-height: 28px;
    }
    
    .opticache-settings-form .submit .opticache-donation-text {
        display: none;
    }
}

/* ============================================
   PRELOAD STATUS
   ============================================ */

#opticache-preload-status-text.preload-running {
    color: #0a7934;
    font-weight: 600;
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */

.opticache-toast {
    position: fixed;
    top: 50px;
    right: 50px;
    min-width: 200px;
    max-width: 420px;
    background: #caf2d7;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%);
    transition: all 0.3s ease;
    border: 1px solid #0a7934;
    overflow: hidden;
}

.opticache-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.opticache-toast-icon {
    width: 24px;
    height: 24px;
    background: #0a7934;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}

.opticache-toast-icon svg {
    width: 14px;
    height: 14px;
}

.opticache-toast-content {
    flex: 1;
}

.opticache-toast-title {
    font-weight: 600;
    font-size: 15px;
    color: #0a7934;
    margin-bottom: 2px;
}

.opticache-toast-message {
    font-size: 14px;
    color: #374151;
}

.opticache-toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #0a7934;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.opticache-toast-close:hover {
    color: #065f27;
}

.opticache-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: #0a7934;
    width: 0%;
    transform-origin: left;
    animation: none;
}

.opticache-toast.show .opticache-toast-progress {
    animation: toastProgress 1.5s linear forwards;
}

/* Icon visibility - show success by default, error when .toast-error class */
.opticache-toast .opticache-toast-icon .icon-error {
    display: none;
}

.opticache-toast .opticache-toast-icon .icon-success {
    display: block;
}

.opticache-toast.toast-error .opticache-toast-icon .icon-success {
    display: none;
}

.opticache-toast.toast-error .opticache-toast-icon .icon-error {
    display: block;
}

/* Error toast - same structure as base toast, just red colors */
.opticache-toast.toast-error {
    background: #f8d7da;
    border: 1px solid #d63638;
}

.opticache-toast.toast-error .opticache-toast-icon {
    background: #d63638;
}

.opticache-toast.toast-error .opticache-toast-title {
    color: #d63638;
}

.opticache-toast.toast-error .opticache-toast-close {
    color: #d63638;
}

.opticache-toast.toast-error .opticache-toast-close:hover {
    color: #a02a2a;
}

.opticache-toast.toast-error .opticache-toast-progress {
    background: #d63638;
    animation: toastProgress 2.5s linear forwards;
}

@keyframes toastProgress {
    from {
        width: 0%;
    }
    to {
        width: 100%;
    }
}

/* ============================================
   DONUT CHARTS
   ============================================ */

.opticache-donut-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.opticache-donut-box {
    background: #fff;
    border: 1px solid #b9b9b9;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    text-align: center;
    min-width: 195px;
    flex: 1;
    max-width: 195px;
}

.opticache-donut-chart {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 15px;
}

.opticache-donut-chart svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.opticache-donut-chart circle {
    fill: none;
    stroke-width: 12;
}

.opticache-donut-chart .donut-bg {
    stroke: #e5e7eb;
}

.opticache-donut-chart .donut-fill {
    stroke: #3b82f6;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}

.opticache-donut-chart .donut-fill.green {
    stroke: #22c55e;
}

.opticache-donut-chart .donut-fill.yellow {
    stroke: #eab308;
}

.opticache-donut-chart .donut-fill.red {
    stroke: #ef4444;
}

.opticache-donut-chart .donut-fill.orange {
    stroke: #f97316;
}

/* Animated OPcache ring */
.opticache-animated-ring .opcache-ring {
    animation: opcache-pulse 2s ease-in-out infinite;
}

@keyframes opcache-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Memory usage bar */
.opticache-memory-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    margin: 10px 0 5px 0;
    overflow: hidden;
}

.opticache-memory-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e 0%, #eab308 50%, #ef4444 100%);
    background-size: 200% 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    animation: memory-gradient 3s ease infinite;
}

@keyframes memory-gradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.opticache-donut-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
}

.opticache-donut-label {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 5px;
}

.opticache-donut-size {
    font-size: 13px;
    color: #9ca3af;
}

.opticache-donut-box .button {
    margin-top: 15px;
}

.opticache-button-tooltip-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 15px;
}

.opticache-button-tooltip-wrap .button {
    margin-top: 0;
    margin-left: 25px;
}

/* ============================================
   OBJECT CACHE METRICS
   ============================================ */

.opticache-metrics-tab {
    transition: all 0.2s ease;
}

.opticache-metrics-tab.active {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.opticache-metrics-tab:hover {
    border-color: #2271b1;
}

#opticache-metrics-chart {
    /* Chart fills its container via absolute positioning */
}

#opticache-metrics-grid {
    position: relative;
}

/* Object Cache horizontal bar animation */
.opticache-object-bar-fill {
    animation: object-bar-shimmer 2s ease-in-out infinite;
    background-size: 200% 100%;
}

@keyframes object-bar-shimmer {
    0% { background-position: 100% 0; }
    50% { background-position: 0% 0; }
    100% { background-position: 100% 0; }
}

/* ============================================
   METRICS REFRESH BUTTON
   ============================================ */

.opticache-metrics-refresh {
    padding: 0;
    width: 40px;
    height: 30px;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    background: #f6f7f7;
    cursor: pointer;
    transition: all 0.2s ease;
}

.opticache-metrics-refresh:hover {
    border-color: #2271b1;
    color: #2271b1;
    background: #f0f0f1;
}

.opticache-metrics-refresh .dashicons {
    width: 20px;
    height: 20px;
    font-size: 20px;
    line-height: 20px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.opticache-metrics-refresh .dashicons:before {
    line-height: 1;
}

.opticache-metrics-refresh.spinning .dashicons {
    animation: opticache-spin 1s linear infinite;
    transform-origin: center center;
}

@keyframes opticache-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   METRICS BASELINE LEGEND
   ============================================ */

.opticache-metrics-legend {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 15px;
    font-size: 11px;
    color: #6b7280;
    z-index: 10;
}

.opticache-metrics-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.opticache-metrics-legend-line {
    width: 20px;
    height: 4px;
    border-radius: 1px;
}

.opticache-metrics-legend-line.baseline-memory {
    background: #059669;
}

/* ============================================
   CUSTOM RULES CODE EDITOR
   ============================================ */

.opticache-code-editor-wrap {
    max-width: 765px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    background: #f6f7f7;
    overflow: hidden;
}

.opticache-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f0f0f1;
    border-bottom: 1px solid #c3c4c7;
}

.opticache-editor-toolbar .button-small {
    padding: 0 8px;
    line-height: 2;
    min-height: 28px;
}

.opticache-editor-info {
    margin-left: auto;
    font-size: 12px;
    color: #646970;
}

.opticache-code-editor {
    display: flex;
    min-height: 350px;
    max-height: 500px;
    overflow: hidden;
}

.opticache-line-numbers {
    width: 35px;
    padding: 12px 8px;
    background: #f0f0f1;
    border-right: 1px solid #c3c4c7;
    text-align: right;
    font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #8c8f94;
    user-select: none;
    overflow: hidden;
}

.opticache-line-numbers span {
    display: block;
}

.opticache-code-textarea {
    flex: 1;
    padding: 12px;
    border: none;
    outline: none;
    resize: none;
    font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
    font-size: 13px;
    line-height: 1.6;
    background: #fff;
    color: #1e1e1e;
    overflow-y: auto;
    white-space: pre;
    tab-size: 4;
}

.opticache-code-textarea:focus {
    box-shadow: none;
}

.opticache-editor-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f0f0f1;
    border-top: 1px solid #c3c4c7;
}

#opticache-test-result {
    font-size: 13px;
}

#opticache-test-result.success {
    color: #00a32a;
}

#opticache-test-result.error {
    color: #d63638;
}

/* ============================================
   ORIGINAL HTACCESS MODAL
   ============================================ */

.opticache-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.opticache-modal-content {
    background: #fff;
    width: 90%;
    max-width: 765px;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.opticache-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid #dcdcde;
    background: #f6f7f7;
    border-radius: 8px 8px 0 0;
}

.opticache-modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #1d2327;
}

.opticache-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #646970;
    padding: 0;
    width: 30px;
    height: 30px;
}

.opticache-modal-close:hover {
    color: #d63638;
}

.opticache-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.opticache-modal-body .description {
    margin-bottom: 15px;
}

.opticache-original-content {
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 15px;
    font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    margin: 0;
    color: #1e1e1e;
}

.opticache-modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #dcdcde;
    background: #f6f7f7;
    border-radius: 0 0 8px 8px;
}

.opticache-modal-footer .dashicons {
    vertical-align: middle;
    margin-right: 3px;
}

/* Spin animation for loading states */
.dashicons.spin {
    animation: opticache-spin 1s linear infinite;
}

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

/* ============================================
   EDITOR TABS
   ============================================ */

.opticache-editor-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 0;
    max-width: 765px;
}

#editor-description-current,
#editor-description-original {
    max-width: 765px;
}

.opticache-editor-tab {
    border-radius: 4px 4px 0 0;
    border-bottom: none;
    background: #f0f0f1;
    color: #50575e;
}

.opticache-editor-tab.active {
    background: #fff;
    border-bottom-color: #fff;
    color: #1d2327;
    font-weight: 500;
}

.opticache-editor-panel {
    display: none;
}

.opticache-editor-panel.active {
    display: block;
}

.opticache-code-editor-wrap.opticache-readonly {
    background: #f9f9f9;
}

.opticache-code-editor-wrap.opticache-readonly .opticache-code-textarea {
    background: #f6f7f7;
    color: #50575e;
    cursor: default;
}

.opticache-readonly-badge {
    background: #dcdcde;
    color: #50575e;
    padding: 0px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

/* ============================================
   VIEW CODE EYE ICON
   ============================================ */

.opticache-view-code-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    margin-left: 8px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.15s ease;
    vertical-align: middle;
}

.opticache-view-code-btn:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* Eye Icon using SVG */
.opticache-eye-icon {
    width: 20px;
    height: 20px;
    background-image: url('../images/review-eye.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transform: translateY(-3px);
}

/* ============================================
   VIEW CODE MODAL
   ============================================ */

.opticache-code-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.opticache-code-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.opticache-code-modal {
    position: fixed;
    top: 150px;
    left: 50%;
    transform: translateX(-50%) translateY(-30px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 550px;
    width: 90%;
    max-height: calc(100vh - 350px);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease-out;
}

.opticache-code-modal-overlay.active .opticache-code-modal {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.opticache-code-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
    background: #f6f7f7;
    border-radius: 8px 8px 0 0;
}

.opticache-code-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #1d2327;
    font-weight: 600;
}

.opticache-code-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #787c82;
    cursor: pointer;
    padding: 0;
    padding-bottom: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
}

.opticache-code-modal-close:hover {
    background: #dcdcde;
    color: #1d2327;
}

.opticache-code-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.opticache-code-modal-body pre {
    margin: 0;
    padding: 15px;
    background: #f0f0f1;
    color: #2c3338;
    border-radius: 4px;
    border: 1px solid #dcdcde;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
    tab-size: 4;
}

.opticache-code-modal-body .code-comment {
    color: #646970;
}

.opticache-code-modal-body .code-directive {
    color: #996800;
}

.opticache-code-modal-body .code-value {
    color: #8abeb7;
}

/* ============================================
   ALERT BOXES
   ============================================ */

.opticache-alert {
    display: flex;
    align-items: flex-start;
    padding: 15px 18px;
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: 15px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    width: 730px;
    box-sizing: border-box;
}

.opticache-alert-icon {
    flex-shrink: 0;
    font-size: 18px;
    margin-right: 12px;
    line-height: 1.4;
}

.opticache-alert-content {
    flex: 1;
}

.opticache-alert-content strong {
    display: inline;
    margin-right: 5px;
}

/* Conflict alert - burgundy */
.opticache-alert-conflict {
    background: #fcebea;
    color: #8b1a1a;
}

.opticache-alert-conflict .opticache-alert-icon {
    color: #a31515;
}

/* Warning alert - pastel yellow */
.opticache-alert-warning {
    background: #fef8e7;
    color: #6d5c0f;
}

.opticache-alert-warning .opticache-alert-icon {
    color: #b8860b;
}

/* Dismissible alert */
.opticache-alert-dismissible {
    position: relative;
    padding-right: 40px;
}

.opticache-alert-dismiss {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #6d5c0f;
    cursor: pointer;
    padding: 0;
    opacity: 0.7;
}

.opticache-alert-dismiss:hover {
    opacity: 1;
}

/* Dismissible WordPress notices */
.opticache-dismissible-notice {
    padding-right: 35px;
}

.opticache-notice-dismiss {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    color: #826200;
    cursor: pointer;
    padding: 0;
    opacity: 0.7;
}

.opticache-notice-dismiss:hover {
    opacity: 1;
}
