/**
 * dialogs.css - Dialog Component Styles (CSP-konform)
 * 
 * Verwendet von: content-sanitizer.js, api-key-manager.js, main.js
 */

/* ===== DIALOG BASE ===== */
dialog {
    border: none;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    background: #1a2332;
    color: #e7ecf3;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;

    /* Resizable - User kann Größe ändern */
    resize: both;
    min-width: 320px;
    min-height: 200px;
}

/* Resize-Indikator (kleine Linie rechts unten) */
dialog::after {
    content: '';
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: linear-gradient(
        135deg,
        transparent 0%,
        transparent 40%,
        rgba(255, 255, 255, 0.2) 40%,
        rgba(255, 255, 255, 0.2) 45%,
        transparent 45%,
        transparent 55%,
        rgba(255, 255, 255, 0.2) 55%,
        rgba(255, 255, 255, 0.2) 60%,
        transparent 60%
    );
    pointer-events: none;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

/* ===== DIALOG CONTENT ===== */
.dialog-content {
    padding: 24px;
    min-width: 400px;
}

@media (max-width: 768px) {
    .dialog-content {
        min-width: 280px;
        padding: 16px;
    }
}

/* ===== DIALOG HEADER ===== */
.dialog-content h3 {
    margin: 0 0 20px 0;
    font-size: 1.5em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dialog-content h4 {
    margin: 16px 0 8px 0;
    font-size: 1.1em;
    font-weight: 600;
    color: #4da6ff;
}

/* ===== DIALOG BUTTONS ===== */
.dialog-buttons {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.dialog-buttons button {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.dialog-buttons button.primary {
    background: #4da6ff;
    color: white;
}

.dialog-buttons button.primary:hover {
    background: #3d8ce0;
}

.dialog-buttons button.secondary {
    background: #2a3654;
    color: #e7ecf3;
}

.dialog-buttons button.secondary:hover {
    background: #364566;
}

.dialog-buttons button.ghost {
    background: transparent;
    color: #8b9dc3;
    border: 1px solid #2a3654;
}

.dialog-buttons button.ghost:hover {
    background: #2a3654;
}

.dialog-buttons button.danger {
    background: #dc3545;
    color: white;
}

.dialog-buttons button.danger:hover {
    background: #c82333;
}

/* ===== FORM ELEMENTS ===== */
.dialog-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #2a3654;
    border-radius: 6px;
    background: #0b1020;
    color: #e7ecf3;
    font-size: 14px;
    font-family: 'Monaco', 'Menlo', monospace;
}

.dialog-input:focus {
    outline: none;
    border-color: #4da6ff;
    box-shadow: 0 0 0 3px rgba(77, 166, 255, 0.1);
}

.dialog-input::placeholder {
    color: #5a6c8a;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #8b9dc3;
}

/* ===== DIALOG LABEL SPACING ===== */
.dialog-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #8b9dc3;
}

.dialog-label-spaced {
    display: block;
    margin-top: 15px;
    margin-bottom: 6px;
    font-weight: 500;
    color: #8b9dc3;
}

/* ===== UNSAFE CONTENT WARNING DIALOG ===== */
.unsafe-content-dialog {
    min-width: 500px;
}

.warning-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #2a3654;
}

.warning-icon {
    font-size: 2em;
}

/* ===== COST CALCULATOR BOX ===== */
.cost-calculator-box {
    background: linear-gradient(135deg, rgba(77, 166, 255, 0.1) 0%, rgba(33, 150, 243, 0.1) 100%);
    border: 2px solid #4da6ff;
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
}

.cost-title {
    color: #4da6ff !important;
    font-size: 1.2em !important;
    margin: 0 0 12px 0 !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cost-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cost-details p {
    margin: 0 !important;
    padding: 6px 0;
    font-size: 14px;
    line-height: 1.6;
}

.cost-details strong {
    color: #e7ecf3;
    font-weight: 600;
}

.cost-rate {
    color: #8b9dc3;
    font-style: italic;
}

.cost-promo {
    background: rgba(76, 175, 80, 0.15);
    border-left: 4px solid #4caf50;
    padding: 10px 12px !important;
    border-radius: 6px;
    color: #4caf50 !important;
    font-weight: 600 !important;
    margin-top: 8px !important;
}

.cost-payment {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    padding: 12px !important;
    margin-top: 12px !important;
}

.cost-payment p {
    margin: 4px 0 !important;
}

.payment-address code,
.payment-paymail code {
    background: #0b1020;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    word-break: break-all;
    color: #ffd700;
    font-family: 'Monaco', 'Menlo', monospace;
}

.payment-paymail {
    margin-top: 8px !important;
}

.cost-link {
    margin-top: 8px !important;
    padding-top: 8px;
    border-top: 1px solid rgba(77, 166, 255, 0.3);
}

.cost-link a {
    color: #4da6ff;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.cost-link a:hover {
    color: #3d8ce0;
    text-decoration: underline;
}

.warning-body {
    margin-bottom: 20px;
}

.warning-body p {
    margin: 0 0 12px 0;
}

.issue-list {
    list-style: none;
    padding: 0;
    margin: 12px 0;
    background: #0b1020;
    border-radius: 6px;
    padding: 12px;
}

.issue-list li {
    padding: 6px 0;
    border-bottom: 1px solid #1a2332;
}

.issue-list li:last-child {
    border-bottom: none;
}

.issue-list li::before {
    content: '⚠️ ';
    margin-right: 8px;
}

.warning-note {
    padding: 12px;
    background: rgba(77, 166, 255, 0.1);
    border-left: 4px solid #4da6ff;
    border-radius: 4px;
    margin: 12px 0;
    font-size: 13px;
}

.warning-note.secondary {
    background: rgba(139, 157, 195, 0.1);
    border-left-color: #8b9dc3;
}

.warning-note.info {
    background: rgba(33, 150, 243, 0.1);
    border-left-color: #2196f3;
}

.warning-note.critical {
    background: rgba(255, 0, 0, 0.15);
    border-left-color: #ff0000;
}

.warning-note strong {
    display: block;
    margin-bottom: 4px;
}

/* ===== API KEY DIALOG ===== */
.api-key-dialog {
    min-width: 600px;
}

.api-key-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #2a3654;
}

.api-key-section:last-of-type {
    border-bottom: none;
}

.key-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 8px 0;
}

.key-input-group input {
    flex: 1;
}

.key-input-group button {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: #2a3654;
    color: #e7ecf3;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.key-input-group button:hover {
    background: #364566;
}

.toggle-visibility {
    width: 40px;
    padding: 8px !important;
}

.test-key {
    background: #28a745 !important;
}

.test-key:hover {
    background: #218838 !important;
}

.key-test-result {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
}

.key-test-success {
    background: rgba(40, 167, 69, 0.2);
    color: #28a745;
    border: 1px solid #28a745;
}

.key-test-error {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
    border: 1px solid #dc3545;
}

.api-key-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 20px 0;
    padding: 16px;
    background: #0b1020;
    border-radius: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-item .muted {
    font-size: 12px;
    color: #5a6c8a;
}

.stat-item .ok {
    color: #28a745;
    font-weight: 600;
}

/* ===== BOOKMARK DIALOG ===== */
.bookmark-item {
    padding: 12px;
    margin-bottom: 8px;
    background: #0b1020;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.bookmark-item:hover {
    background: #1a2332;
}

.bookmark-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.bookmark-txid {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    color: #5a6c8a;
}

.bookmark-date {
    font-size: 11px;
    color: #5a6c8a;
    margin-top: 4px;
}

/* ===== QR DIALOG ===== */
#qrContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: 8px;
    margin: 20px 0;
}

#qrContainer img {
    max-width: 100%;
    height: auto;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .api-key-dialog,
    .unsafe-content-dialog {
        min-width: 280px;
        max-width: 95vw;
    }
    
    .key-input-group {
        flex-wrap: wrap;
    }

    .key-input-group input {
        width: 100%;
    }
}

/* ===== DIALOG HEADER MIT X-BUTTON ===== */
.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px 12px 0 0;
    margin: 0;
}

.dialog-title {
    margin: 0 !important;
    font-size: 1.5em;
    font-weight: 600;
    flex: 1;
}

/* X-Button oben rechts */
.dialog-close-btn {
    background: none;
    border: none;
    color: #8b96a6;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    margin: 0;
    transition: all 0.2s;
    border-radius: 6px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ff4444;
    transform: scale(1.1);
}

.dialog-close-btn:active {
    transform: scale(0.95);
}

/* Mobile: Größerer Touch-Target */
@media (max-width: 768px) {
    .dialog-close-btn {
        min-width: 48px;
        min-height: 48px;
        font-size: 32px;
    }

    .dialog-header {
        padding: 16px;
    }
}

/* ===== BACKUP HISTORY DIALOG ===== */
.backup-history {
    min-width: 400px;
}

.backup-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.backup-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: all 0.2s;
}

.backup-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.backup-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.backup-info strong {
    color: #e7ecf3;
    font-size: 1em;
}

.backup-info .muted {
    color: #8b96a6;
    font-size: 0.85em;
}

/* Mobile Backup History */
@media (max-width: 768px) {
    .backup-history {
        min-width: 280px;
    }

    .backup-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .backup-item button {
        width: 100%;
    }
}

/* ===== AUTO-SAVE INDICATOR ===== */
.dialog-save-indicator {
    position: absolute;
    top: 24px;
    right: 60px;
    font-size: 0.85em;
    color: #8b96a6;
    opacity: 0;
    transition: opacity 0.3s;
}

.dialog-save-indicator.saving {
    opacity: 1;
    color: #ffa500;
}

.dialog-save-indicator.saved {
    opacity: 1;
    color: #4caf50;
}

/* Animation für Auto-Save */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.dialog-save-indicator.saving::before {
    content: '💾 ';
    animation: pulse 1s infinite;
}

.dialog-save-indicator.saved::before {
    content: '✅ ';
}

/* ===== CHAINDISK FILE SELECTOR ===== */
.chaindisk-files-container {
    min-width: 500px;
    max-width: 700px;
}

.chaindisk-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #2a3654;
}

.chaindisk-header h3 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
    color: #e7ecf3;
}

.chaindisk-header .file-count {
    background: rgba(77, 166, 255, 0.15);
    color: #4da6ff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.chaindisk-file-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 8px;
}

/* Custom Scrollbar */
.chaindisk-file-list::-webkit-scrollbar {
    width: 8px;
}

.chaindisk-file-list::-webkit-scrollbar-track {
    background: #0b1020;
    border-radius: 4px;
}

.chaindisk-file-list::-webkit-scrollbar-thumb {
    background: #2a3654;
    border-radius: 4px;
}

.chaindisk-file-list::-webkit-scrollbar-thumb:hover {
    background: #364566;
}

.chaindisk-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #0b1020;
    border: 1px solid #2a3654;
    border-radius: 8px;
    transition: all 0.2s;
    cursor: pointer;
}

.chaindisk-file-item:hover {
    background: #1a2332;
    border-color: #4da6ff;
    transform: translateX(4px);
}

.chaindisk-file-item.selected {
    background: rgba(77, 166, 255, 0.1);
    border-color: #4da6ff;
}

.file-icon {
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    color: #e7ecf3;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 12px;
    color: #5a6c8a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-meta::before {
    content: '';
}

.chaindisk-file-item button {
    padding: 6px 16px;
    border-radius: 6px;
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chaindisk-file-item button.secondary {
    background: #2a3654;
    color: #e7ecf3;
}

.chaindisk-file-item button.secondary:hover {
    background: #4da6ff;
    color: white;
}

.chaindisk-file-item button.small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chaindisk-files-container {
        min-width: 280px;
        max-width: 95vw;
    }

    .chaindisk-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .chaindisk-file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .file-icon {
        font-size: 28px;
    }

    .chaindisk-file-item button {
        width: 100%;
    }

    .file-info {
        width: 100%;
    }
}

/* ===== API STATUS DIALOG ===== */
.api-status-container {
    min-width: 350px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #0b1020;
    border-radius: 6px;
    border: 1px solid #2a3654;
}

.status-label {
    font-weight: 500;
    color: #8b9dc3;
}

.status-value {
    font-family: 'Monaco', 'Menlo', monospace;
    font-weight: 600;
    color: #e7ecf3;
}

.status-value.ok {
    color: #28a745;
}

.status-value.warn {
    color: #ffa500;
}

.status-value.error {
    color: #dc3545;
}

@media (max-width: 768px) {
    .api-status-container {
        min-width: 280px;
    }

    .status-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}
