/**
 * translate.press.zone Admin Styles
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    --presszone-translate-color-success: #46b450;
    --presszone-translate-color-error: #dc3232;
    --presszone-translate-color-warning: #ffb900;
    --presszone-translate-color-info: #00a0d2;
}

.dark-mode {
    --presszone-translate-color-success: #5cb85c;
    --presszone-translate-color-error: #e74c3c;
    --presszone-translate-color-warning: #f39c12;
    --presszone-translate-color-info: #3498db;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.presszone-translate-hidden {
    display: none !important;
}

.presszone-translate-modal--hidden {
    display: none;
}

.presszone-translate-col-datetime {
    width: 180px;
}

.presszone-translate-col-type {
    width: 200px;
}

.presszone-translate-col-severity {
    width: 100px;
}

.presszone-translate-col-ip {
    width: 150px;
}

.presszone-translate-icon-success {
    color: var(--presszone-translate-color-success);
}

.presszone-translate-icon-error {
    color: var(--presszone-translate-color-error);
}

.presszone-translate-progress-bar {
    width: 0%;
    transition: width 0.3s ease;
}

.presszone-translate-usage-bar {
    width: var(--presszone-translate-usage-percentage, 0%);
}

.presszone-translate-cursor-default {
    cursor: default;
}

.presszone-translate-inline-form {
    display: inline-block;
}

.presszone-translate-fade-out {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* ==========================================================================
   Settings Page
   ========================================================================== */

.presszone-translate-settings {
    max-width: 1200px;
}

.presszone-translate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 15px 20px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    gap: 20px;
    flex-wrap: wrap;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.status-indicator.status-connected {
    background-color: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.status-indicator.status-disconnected {
    background-color: #ef4444;
}

.status-indicator.status-verifying {
    background-color: #eab308;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.status-text {
    font-weight: 500;
    font-size: 14px;
}

/* Credit Balance Display */
.credit-balance-header {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-end;
}

.credit-balance-display {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f0f9ff;
    border: 1px solid #0ea5e9;
    border-radius: 4px;
    font-size: 14px;
}

.credit-balance-display.credit-balance-low {
    background: #fef3c7;
    border-color: #f59e0b;
}

.credit-balance-label {
    font-weight: 500;
    color: #334155;
}

.credit-balance-value {
    font-weight: 700;
    font-size: 16px;
    color: #0369a1;
}

.credit-balance-display.credit-balance-low .credit-balance-value {
    color: #d97706;
}

.credit-balance-unit {
    font-size: 13px;
    color: #64748b;
}

.credit-balance-tier {
    font-size: 12px;
    color: #64748b;
    font-style: italic;
}

.credit-balance-warning {
    margin: 0;
    padding: 6px 10px;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 4px;
    color: #92400e;
    font-size: 12px;
    font-weight: 500;
}

.presszone-translate-section {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
    margin: 20px 0;
}

.presszone-translate-section h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 18px;
}

.presszone-translate-section .description {
    color: #646970;
    font-size: 13px;
    margin-top: 5px;
}

.api-key-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.api-key-wrapper input[type="password"],
.api-key-wrapper input[type="text"] {
    flex: 1;
    max-width: 400px;
}

#api-key-status {
    margin-top: 8px;
    font-weight: 500;
}

#api-key-status.success {
    color: #22c55e;
}

#api-key-status.error {
    color: #ef4444;
}



/* Usage progress bar */
.usage-progress {
    width: 100%;
    max-width: 500px;
    height: 24px;
    background: #f3f4f6;
    border-radius: 12px;
    overflow: hidden;
    margin: 10px 0;
    border: 1px solid #e5e7eb;
}

.usage-bar {
    height: 100%;
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.usage-bar.high-usage {
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.usage-bar.critical-usage {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

#usage-stats p {
    margin: 8px 0;
}

#usage-stats strong {
    font-weight: 600;
    color: #1e293b;
}

/* Button states */
.button.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.button.loading::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Admin notices */
.notice.presszone-translate-notice {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.notice.presszone-translate-notice::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.notice.notice-success.presszone-translate-notice::before {
    content: "✓";
    color: #22c55e;
    font-weight: bold;
    font-size: 18px;
}

.notice.notice-error.presszone-translate-notice::before {
    content: "✕";
    color: #ef4444;
    font-weight: bold;
    font-size: 18px;
}

/* Responsive */
@media (max-width: 768px) {
    .presszone-translate-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .credit-balance-header {
        align-items: flex-start;
        width: 100%;
    }

    .credit-balance-display {
        flex-wrap: wrap;
    }

    .api-key-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .api-key-wrapper input {
        max-width: none;
    }

    .form-table th,
    .form-table td {
        display: block;
        width: 100%;
    }

    .form-table th {
        padding-bottom: 5px;
    }

    .form-table td {
        padding-top: 0;
    }
}

/* Accessibility */
.button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Dark mode support (if WordPress adds it) */
@media (prefers-color-scheme: dark) {
    .presszone-translate-section {
        background: #1e1e1e;
        border-color: #3e3e3e;
        color: #e0e0e0;
    }

    .presszone-translate-section h2 {
        border-bottom-color: #3e3e3e;
        color: #fff;
    }

    .form-table fieldset label {
        background: #2a2a2a;
        border-color: #3e3e3e;
        color: #e0e0e0;
    }

    .form-table fieldset label:hover {
        background: #333;
        border-color: #4a9eff;
    }

    .usage-progress {
        background: #2a2a2a;
        border-color: #3e3e3e;
    }

    #usage-stats strong {
        color: #fff;
    }

    .credit-balance-display {
        background: #1e3a4c;
        border-color: #0ea5e9;
    }

    .credit-balance-display.credit-balance-low {
        background: #3a351e;
        border-color: #f59e0b;
    }

    .credit-balance-label {
        color: #cbd5e1;
    }

    .credit-balance-value {
        color: #7dd3fc;
    }

    .credit-balance-display.credit-balance-low .credit-balance-value {
        color: #fbbf24;
    }

    .credit-balance-unit,
    .credit-balance-tier {
        color: #94a3b8;
    }

    .credit-balance-warning {
        background: #3a351e;
        border-color: #f59e0b;
        color: #fde68a;
    }
}

/* ==========================================================================
   Meta Box Styles
   ========================================================================== */

.presszone-translate-metabox {
    padding: 0;
}

/* Character Estimate Box (legacy class names kept for compatibility) */
.presszone-token-estimate {
    margin: 15px 0;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.presszone-token-estimate-header {
    margin-bottom: 10px;
}

.presszone-token-estimate-label {
    font-weight: 600;
    color: #333;
}

.presszone-token-estimate-body {
    font-size: 14px;
}

.presszone-token-estimate-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
}

.presszone-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: presszone-token-spin 1s linear infinite;
}

@keyframes presszone-token-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.presszone-token-estimate-list {
    list-style: none;
    margin: 0 0 10px 0;
    padding: 0;
}

.presszone-token-estimate-list li {
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
}

.presszone-token-estimate-list .lang-name {
    color: #555;
}

.presszone-token-estimate-list .token-value,
.presszone-token-estimate-list .character-value {
    font-weight: 600;
    color: #2271b1;
}

.presszone-token-estimate-total {
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    font-size: 15px;
}

.presszone-token-estimate-total strong {
    color: #333;
}

.presszone-token-estimate-credits {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 3px;
    font-size: 13px;
}

.presszone-token-estimate-credits.sufficient {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.presszone-token-estimate-credits.insufficient {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Dark Mode Support */
.dark-mode .presszone-token-estimate {
    background: #2c2c2c;
    border-color: #444;
}

.dark-mode .presszone-token-estimate-label {
    color: #e0e0e0;
}

.dark-mode .presszone-token-estimate-list .lang-name {
    color: #b0b0b0;
}

.dark-mode .presszone-token-estimate-list .token-value,
.dark-mode .presszone-token-estimate-list .character-value {
    color: #5ba3d0;
}

.dark-mode .presszone-token-estimate-total {
    border-top-color: #444;
}

.dark-mode .presszone-token-estimate-total strong {
    color: #e0e0e0;
}

.dark-mode .presszone-token-estimate-credits.sufficient {
    background: #1e4620;
    color: #90ee90;
    border-color: #2d5a2e;
}

.dark-mode .presszone-token-estimate-credits.insufficient {
    background: #4a1f1f;
    color: #ffb3b3;
    border-color: #6b2828;
}

/* Job Progress */
.presszone-job-progress {
    margin: 12px 0;
    padding: 10px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}

.presszone-job-progress-title {
    margin: 0 0 10px 0;
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.presszone-job-progress-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.presszone-job-progress-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-bottom: 6px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 3px;
    font-size: 12px;
    flex-wrap: wrap;
}

.presszone-job-progress-item:last-child {
    margin-bottom: 0;
}

.presszone-job-lang {
    font-weight: 600;
    color: #1e293b;
}

.presszone-job-status {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.presszone-job-status-pending {
    background: #fef3c7;
    color: #92400e;
}

.presszone-job-status-processing {
    background: #dbeafe;
    color: #1e3a8a;
}

.presszone-job-status-completed {
    background: #d1fae5;
    color: #065f46;
}

.presszone-job-status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.presszone-job-status-cancelled {
    background: #f3f4f6;
    color: #6b7280;
}

.presszone-job-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.presszone-job-error {
    width: 100%;
    margin-top: 4px;
    padding: 4px 6px;
    background: #fee2e2;
    border-radius: 3px;
    color: #991b1b;
    font-size: 11px;
}

.presszone-job-success-info {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
    padding: 4px 6px;
    background: #d1fae5;
    border-radius: 3px;
    font-size: 11px;
}

.presszone-job-characters {
    color: #065f46;
}

.presszone-job-cost {
    color: #065f46;
    font-weight: 600;
}

.presszone-job-progress-error {
    margin-top: 8px;
    padding: 8px;
    background: #fee2e2;
    border: 1px solid #ef4444;
    border-radius: 3px;
    color: #991b1b;
    font-size: 12px;
}

.presszone-job-progress-success {
    margin-top: 8px;
    padding: 8px;
    background: #d1fae5;
    border: 1px solid #22c55e;
    border-radius: 3px;
    color: #065f46;
    font-size: 12px;
}

.presszone-translate-metabox .language-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.presszone-translate-metabox .language-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.presszone-translate-metabox .language-grid label:hover {
    background: #f3f4f6;
    border-color: #2271b1;
}

.presszone-translate-metabox .language-grid label.has-translation {
    background: #f0f9ff;
    border-color: #0ea5e9;
    opacity: 0.7;
}

.presszone-translate-metabox .language-grid label .translation-badge {
    display: inline-block;
    font-size: 10px;
    color: #0369a1;
    margin-left: auto;
}

.presszone-translate-metabox .selection-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}