/**
 * Security TOTP Styles
 * 
 * Styles for TOTP setup, verification, and management interfaces
 */

/* ===========================================
   TOTP Messages
   =========================================== */
.totp-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
}

.totp-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 4px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease-out;
}

.totp-message-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.totp-message-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.totp-message-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.totp-message-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.message-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
    margin-left: 10px;
    padding: 0;
    line-height: 1;
}

.message-close:hover {
    opacity: 1;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===========================================
   TOTP Modals
   =========================================== */
.totp-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.totp-modal.active {
    opacity: 1;
    visibility: visible;
}

.totp-modal .modal-dialog {
    background: #fff;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.totp-modal.active .modal-dialog {
    transform: scale(1);
}

.totp-modal .modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.totp-modal .modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
}

.totp-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.7;
    padding: 0;
    line-height: 1;
    color: #666;
}

.totp-modal-close:hover {
    opacity: 1;
    color: #333;
}

.totp-modal .modal-body {
    padding: 24px;
}

/* ===========================================
   TOTP Setup Content
   =========================================== */
.totp-setup-content .setup-step {
    display: none;
}

.totp-setup-content .setup-step.active {
    display: block;
}

.totp-setup-content h4 {
    margin-top: 0;
    margin-bottom: 16px;
    color: #333;
    font-size: 1.1rem;
}

.totp-setup-content p {
    margin-bottom: 16px;
    color: #666;
    line-height: 1.5;
}

/* QR Code Container */
.qr-code-container {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.totp-qr-code {
    display: block;
    margin: 0 auto 16px;
    border: 4px solid #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 200px;
    width: 100%;
    height: auto;
}

.qr-refresh-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.qr-refresh-btn:hover {
    background: #5a6268;
}

.qr-refresh-btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

/* Manual Entry */
.manual-entry {
    margin-top: 24px;
    padding: 16px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.manual-entry h5 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    color: #495057;
}

.manual-entry p {
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.totp-secret {
    display: block;
    font-family: 'Courier New', monospace;
    background: #f8f9fa;
    padding: 12px;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    word-break: break-all;
    margin-bottom: 12px;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.copy-secret-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s;
}

.copy-secret-btn:hover {
    background: #218838;
}

/* Step Navigation */
.next-step-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 20px;
    transition: background-color 0.2s;
}

.next-step-btn:hover {
    background: #0056b3;
}

/* ===========================================
   TOTP Verification Forms
   =========================================== */
.totp-verify-form,
.backup-code-form {
    margin-top: 16px;
}

.totp-code-input,
.backup-code-input {
    width: 100%;
    padding: 16px;
    font-size: 2rem;
    font-family: 'Courier New', monospace;
    text-align: center;
    letter-spacing: 8px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
    transition: border-color 0.2s, background-color 0.2s;
    margin-bottom: 16px;
}

.totp-code-input:focus,
.backup-code-input:focus {
    outline: none;
    border-color: #007bff;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.totp-code-input::placeholder,
.backup-code-input::placeholder {
    color: #adb5bd;
    opacity: 1;
}

/* Verification Buttons */
.totp-verify-btn,
.backup-verify-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s;
    width: 100%;
    margin-bottom: 12px;
}

.totp-verify-btn:hover,
.backup-verify-btn:hover {
    background: #218838;
}

.totp-verify-btn:disabled,
.backup-verify-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* Form Switch Links */
.show-backup-form,
.show-totp-form {
    background: none;
    border: none;
    color: #007bff;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
    padding: 0;
}

.show-backup-form:hover,
.show-totp-form:hover {
    color: #0056b3;
}

/* ===========================================
   Backup Codes Modal
   =========================================== */
.backup-codes-content .warning-message {
    background: #fff3cd;
    color: #856404;
    padding: 16px;
    border-radius: 6px;
    border: 1px solid #ffeaa7;
    margin-bottom: 24px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.backup-codes-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin: 24px 0;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.backup-code {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    padding: 12px 8px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    letter-spacing: 1px;
    color: #495057;
}

.backup-codes-actions {
    display: flex;
    gap: 12px;
    margin: 24px 0;
    flex-wrap: wrap;
}

.backup-codes-download-btn,
.backup-codes-print-btn {
    flex: 1;
    min-width: 120px;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.backup-codes-download-btn {
    background: #007bff;
    color: white;
}

.backup-codes-download-btn:hover {
    background: #0056b3;
}

.backup-codes-print-btn {
    background: #6c757d;
    color: white;
}

.backup-codes-print-btn:hover {
    background: #5a6268;
}

.completion-message {
    margin-top: 24px;
    padding: 16px;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    text-align: center;
}

.completion-message p {
    margin: 0;
    font-weight: 500;
}

/* ===========================================
   TOTP Status Displays
   =========================================== */
.totp-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 20px;
}

.totp-status-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
}

.totp-status.enabled .totp-status-icon {
    background: #28a745;
    color: white;
}

.totp-status.disabled .totp-status-icon {
    background: #dc3545;
    color: white;
}

.totp-status.setup-pending .totp-status-icon {
    background: #ffc107;
    color: #212529;
}

.totp-status-text {
    flex: 1;
}

.totp-status-text h4 {
    margin: 0 0 4px 0;
    font-size: 1rem;
    color: #333;
}

.totp-status-text p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

.totp-status-actions {
    display: flex;
    gap: 8px;
}

/* TOTP Action Buttons */
.totp-setup-btn,
.totp-disable-btn,
.backup-codes-generate-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.totp-setup-btn {
    background: #007bff;
    color: white;
}

.totp-setup-btn:hover {
    background: #0056b3;
}

.totp-disable-btn {
    background: #dc3545;
    color: white;
}

.totp-disable-btn:hover {
    background: #c82333;
}

.backup-codes-generate-btn {
    background: #6c757d;
    color: white;
}

.backup-codes-generate-btn:hover {
    background: #5a6268;
}

.totp-setup-btn:disabled,
.totp-disable-btn:disabled,
.backup-codes-generate-btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

/* ===========================================
   TOTP Countdown Timer
   =========================================== */
.totp-countdown {
    display: inline-block;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    padding: 4px 8px;
    background: #e9ecef;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #495057;
    margin-left: 8px;
    transition: all 0.2s;
}

.totp-countdown.expiring {
    background: #f8d7da;
    color: #721c24;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===========================================
   User Profile TOTP Section
   =========================================== */
.totp-profile-section {
    margin: 24px 0;
    padding: 20px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.totp-profile-section h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: #333;
    font-size: 1.2rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
}

.totp-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.totp-info-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.totp-info-item label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.totp-info-item .value {
    color: #333;
    font-size: 1rem;
}

.totp-info-item .value.success {
    color: #28a745;
    font-weight: 500;
}

.totp-info-item .value.error {
    color: #dc3545;
    font-weight: 500;
}

.totp-info-item .value.warning {
    color: #ffc107;
    font-weight: 500;
}

/* ===========================================
   Responsive Design
   =========================================== */
@media (max-width: 768px) {
    .totp-modal .modal-dialog {
        width: 95%;
        margin: 10px;
    }
    
    .totp-modal .modal-body {
        padding: 16px;
    }
    
    .totp-messages {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .backup-codes-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 16px;
    }
    
    .backup-code {
        font-size: 0.95rem;
        padding: 10px 6px;
        letter-spacing: 0.5px;
    }
    
    .backup-codes-actions {
        flex-direction: column;
    }
    
    .backup-codes-download-btn,
    .backup-codes-print-btn {
        width: 100%;
    }
    
    .totp-info-grid {
        grid-template-columns: 1fr;
    }
    
    .totp-status-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .totp-setup-btn,
    .totp-disable-btn,
    .backup-codes-generate-btn {
        width: 100%;
        margin-bottom: 8px;
    }
}

@media (max-width: 480px) {
    .totp-code-input,
    .backup-code-input {
        font-size: 1.5rem;
        letter-spacing: 4px;
        padding: 12px;
    }
    
    .backup-codes-list {
        grid-template-columns: 1fr;
    }
    
    .manual-entry {
        padding: 12px;
    }
    
    .totp-secret {
        font-size: 0.8rem;
        padding: 8px;
    }
}

/* ===========================================
   Dark Mode Support (Optional)
   =========================================== */
@media (prefers-color-scheme: dark) {
    .totp-modal .modal-dialog {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .totp-modal .modal-header {
        border-bottom-color: #4a5568;
    }
    
    .totp-modal .modal-title {
        color: #e2e8f0;
    }
    
    .totp-modal-close {
        color: #a0aec0;
    }
    
    .totp-modal-close:hover {
        color: #e2e8f0;
    }
    
    .qr-code-container {
        background: #4a5568;
        border-color: #718096;
    }
    
    .manual-entry {
        background: #4a5568;
        border-color: #718096;
    }
    
    .totp-secret {
        background: #2d3748;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .totp-code-input,
    .backup-code-input {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .totp-code-input:focus,
    .backup-code-input:focus {
        background: #2d3748;
        border-color: #63b3ed;
    }
    
    .backup-codes-list {
        background: #4a5568;
        border-color: #718096;
    }
    
    .backup-code {
        background: #2d3748;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .totp-status {
        background: #4a5568;
        border-color: #718096;
    }
    
    .totp-info-item {
        background: #4a5568;
    }
    
    .totp-info-item label {
        color: #a0aec0;
    }
    
    .totp-info-item .value {
        color: #e2e8f0;
    }
}

/* ===========================================
   Print Styles
   =========================================== */
@media print {
    .totp-modal,
    .totp-messages,
    .totp-setup-btn,
    .totp-disable-btn,
    .backup-codes-generate-btn,
    .qr-refresh-btn,
    .copy-secret-btn {
        display: none !important;
    }
    
    .backup-codes-list {
        background: white !important;
        border: 2px solid #000 !important;
        page-break-inside: avoid;
    }
    
    .backup-code {
        background: white !important;
        border: 1px solid #000 !important;
        color: #000 !important;
    }
    
    .totp-secret {
        background: white !important;
        border: 1px solid #000 !important;
        color: #000 !important;
    }
}