/* Algorithm Card Component Styles */

.algorithm-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.125);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.algorithm-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.algorithm-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--category-color, #667eea);
}

/* Category-specific colors */
.algorithm-card[data-category="block"] { --category-color: #3182ce; }
.algorithm-card[data-category="stream"] { --category-color: #38b2ac; }
.algorithm-card[data-category="hash"] { --category-color: #d69e2e; }
.algorithm-card[data-category="classical"] { --category-color: #dd6b20; }
.algorithm-card[data-category="encoding"] { --category-color: #805ad5; }
.algorithm-card[data-category="compression"] { --category-color: #38a169; }
.algorithm-card[data-category="asymmetric"] { --category-color: #e53e3e; }
.algorithm-card[data-category="special"] { --category-color: #2d3748; }
.algorithm-card[data-category="mac"] { --category-color: #b83280; }
.algorithm-card[data-category="kdf"] { --category-color: #319795; }
.algorithm-card[data-category="ecc"] { --category-color: #9f7aea; }
.algorithm-card[data-category="checksum"] { --category-color: #ed8936; }
.algorithm-card[data-category="mode"] { --category-color: #f56565; }
.algorithm-card[data-category="padding"] { --category-color: #9f7aea; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    flex: 1;
}

.card-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-left: 1rem;
}

.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
}

.badge-category {
    background: var(--category-color, #667eea);
    color: white;
}

.badge-country {
    background: rgba(0, 0, 0, 0.1);
    color: white;
    font-weight: 500;
}

.badge-year {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.card-description {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Loading state */
.algorithm-card.loading {
    pointer-events: none;
}

.algorithm-card.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Highlighted state (for search results) */
.algorithm-card.highlighted {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Category sections */
.palette-section {
    margin-bottom: 1.5rem;
}

.palette-section[data-category="block"] { --category-color: #3182ce; }
.palette-section[data-category="stream"] { --category-color: #38b2ac; }
.palette-section[data-category="hash"] { --category-color: #d69e2e; }
.palette-section[data-category="classical"] { --category-color: #dd6b20; }
.palette-section[data-category="encoding"] { --category-color: #805ad5; }
.palette-section[data-category="compression"] { --category-color: #38a169; }
.palette-section[data-category="asymmetric"] { --category-color: #e53e3e; }
.palette-section[data-category="special"] { --category-color: #2d3748; }
.palette-section[data-category="mac"] { --category-color: #b83280; }
.palette-section[data-category="kdf"] { --category-color: #319795; }
.palette-section[data-category="mode"] { --category-color: #f56565; }
.palette-section[data-category="padding"] { --category-color: #9f7aea; }
.palette-section[data-category="ecc"] { --category-color: #9f7aea; }
.palette-section[data-category="checksum"] { --category-color: #ed8936; }

.palette-header {
    font-weight: 600;
    font-size: 1.125rem;
    color: white;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border-left: 4px solid var(--category-color, #667eea);
}

.algorithms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .algorithms-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .card-badges {
        margin-left: 0;
        margin-top: 0.5rem;
    }
    
    .card-actions {
        flex-direction: column;
    }
}

/* Modal-specific algorithm card adjustments */
.modal-body .algorithm-card {
    margin-bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: default; /* Disable cursor pointer in modal */
}

.modal-body .algorithm-card:hover {
    transform: none; /* Disable hover transform in modal */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.modal-body .algorithm-card .card-actions {
    display: none; /* Hide action buttons in modal since they're not needed */
}

/* ============================================
   MODAL SYSTEM STYLES
   ============================================ */

/* Main Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: block;
}

.modal-content {
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.125);
    border-radius: 12px;
    margin: 5% auto;
    padding: 0;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.125);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, 
        rgba(var(--category-color-rgb, 102, 126, 234), 0.15) 0%, 
        rgba(var(--category-color-rgb, 102, 126, 234), 0.05) 100%);
    backdrop-filter: blur(10px);
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    background: none;
    border: none;
}

.modal-close:hover,
.modal-close:focus {
    color: white;
}

/* Modal category-specific styling */
.modal[data-category="block"] { --category-color-rgb: var(--category-color-block-rgb); }
.modal[data-category="stream"] { --category-color-rgb: var(--category-color-stream-rgb); }
.modal[data-category="hash"] { --category-color-rgb: var(--category-color-hash-rgb); }
.modal[data-category="classical"] { --category-color-rgb: var(--category-color-classical-rgb); }
.modal[data-category="encoding"] { --category-color-rgb: var(--category-color-encoding-rgb); }
.modal[data-category="compression"] { --category-color-rgb: var(--category-color-compression-rgb); }
.modal[data-category="asymmetric"] { --category-color-rgb: var(--category-color-asymmetric-rgb); }
.modal[data-category="special"] { --category-color-rgb: var(--category-color-special-rgb); }
.modal[data-category="mac"] { --category-color-rgb: var(--category-color-mac-rgb); }
.modal[data-category="kdf"] { --category-color-rgb: var(--category-color-kdf-rgb); }
.modal[data-category="ecc"] { --category-color-rgb: var(--category-color-ecc-rgb); }
.modal[data-category="checksum"] { --category-color-rgb: var(--category-color-checksum-rgb); }
.modal[data-category="mode"] { --category-color-rgb: var(--category-color-mode-rgb); }
.modal[data-category="padding"] { --category-color-rgb: var(--category-color-padding-rgb); }
.modal[data-category="unknown"] { --category-color-rgb: 102, 126, 234; }

.modal-body {
    padding: 0;
    color: rgba(255, 255, 255, 0.9);
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.125);
    background: rgba(255, 255, 255, 0.05);
}

.modal-tab {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
}

.modal-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.modal-tab.active {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border-bottom-color: #667eea;
}

.modal-tab-content {
    display: none;
    padding: 1.5rem;
}

.modal-tab-content.active {
    display: block;
}

.tab-content-wrapper {
    max-height: 60vh;
    overflow-y: auto;
}

.tab-content-wrapper h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.125);
    padding-bottom: 0.5rem;
}

/* Algorithm Metadata Modal */
.metadata-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.metadata-modal.visible {
    display: flex;
}

.metadata-content {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.125);
    border-radius: 16px;
    padding: 0;
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.metadata-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
}

.metadata-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.metadata-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1.5rem;
    cursor: pointer;
    color: #ffffff;
    padding: 0.5rem;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.metadata-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.metadata-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

.metadata-tab {
    padding: 1rem 2rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.metadata-tab:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.metadata-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.metadata-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* Metadata Modal Content Styles */
.metadata-description {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
}

.metadata-value {
    color: #ffffff;
    font-weight: 500;
}

.category-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    color: #ffffff !important;
    font-weight: 600;
    font-size: 0.875rem;
}

.status-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
}

.country-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.country-flag {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.status-label {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.status-value {
    font-weight: 600;
}

.status-value.positive {
    color: #38a169;
}

.status-value.negative {
    color: #e53e3e;
}

.references-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.reference-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
}

.reference-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

.reference-link a {
    color: #60a5fa;
    text-decoration: none;
    word-break: break-all;
}

.reference-link a:hover {
    color: #3b82f6;
    text-decoration: underline;
}

.no-data {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    padding: 2rem;
    font-style: italic;
}

.suggested-resources {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.resource-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
}

.resource-item a {
    color: #60a5fa;
    text-decoration: none;
}

.resource-item a:hover {
    color: #3b82f6;
    text-decoration: underline;
}

/* Security Badge Styles */
.badge-security {
    background: rgba(0, 0, 0, 0.1);
    color: white;
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Action Badge for Test Vector Count */
.action-badge {
    background: #667eea;
    color: white;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    margin-left: 0.3rem;
    min-width: 1.2rem;
    text-align: center;
    display: inline-block;
}

/* Enhanced Palette Header */
.palette-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 1.125rem;
    color: white;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border-left: 4px solid var(--category-color, #667eea);
}

.category-title {
    flex: 1;
}

.category-count {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
}

/* Test Vector Styles */
.test-vector-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.test-vector-count {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    font-weight: 500;
}

.test-vectors-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.test-vector-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid #667eea;
    transition: all 0.2s ease;
}

.test-vector-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.test-vector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.test-vector-header h5 {
    margin: 0;
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

.test-result {
    margin-left: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.test-result.success {
    color: #38a169;
}

.test-result.failure {
    color: #e53e3e;
}

.test-result.error {
    color: #dd6b20;
}

.test-result.running {
    color: #3182ce;
}

.test-success {
    color: #38a169;
}

.test-failure {
    color: #e53e3e;
}

.test-error {
    color: #dd6b20;
}

.test-running {
    color: #3182ce;
}

.test-vector-description {
    margin-bottom: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
    font-size: 0.9rem;
}

.test-vector-field {
    margin-bottom: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.875rem;
    line-height: 1.4;
}

.test-vector-field strong {
    color: white;
    font-weight: 600;
    margin-right: 0.5rem;
}

.test-vector-field code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #f8f8f2;
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.test-vector-origin {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
}

.test-vector-origin a {
    color: #667eea;
    text-decoration: none;
}

.test-vector-origin a:hover {
    color: #5a67d8;
    text-decoration: underline;
}

/* Code Block Styles */
.code-block {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
}

.code-block code {
    color: #f8f8f2;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
}

.algorithm-details .detail-row {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.algorithm-details .detail-row:last-child {
    margin-bottom: 0;
}

.algorithm-details strong {
    color: white;
    font-weight: 600;
}

.algorithm-details ul {
    margin: 0.5rem 0 0 1rem;
    padding: 0;
}

.algorithm-details li {
    margin-bottom: 0.25rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Expanded details in modal */
.expanded-details {
    margin-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.125);
    padding-top: 1.5rem;
}

.expanded-details h3 {
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.125);
    padding-bottom: 0.5rem;
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h4 {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border-left: 3px solid var(--category-color, #667eea);
}

.detail-item {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
}

.detail-item:last-child {
    margin-bottom: 0;
}

.detail-item strong {
    color: white;
    font-weight: 600;
}

.link-list {
    margin: 0.5rem 0 0 1rem;
    padding: 0;
}

.link-list li {
    margin-bottom: 0.5rem;
    color: rgba(255, 255, 255, 0.8);
}

.link-list a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s ease;
}

.link-list a:hover {
    color: #5a67d8;
    text-decoration: underline;
}

.vulnerability-list {
    margin: 0.5rem 0 0 1rem;
    padding: 0;
}

.vulnerability-list li {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: rgba(255, 0, 0, 0.1);
    border-left: 3px solid #e53e3e;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.9);
}

.vulnerability-list li em {
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
    display: block;
    margin-top: 0.25rem;
}

/* Modal Responsive Design */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .modal-header,
    .modal-body {
        padding: 1rem;
    }
    
    .expanded-details {
        margin-top: 1rem;
        padding-top: 1rem;
    }
    
    .detail-section h4 {
        font-size: 0.9rem;
        padding: 0.4rem 0.6rem;
    }
    
    .detail-item {
        font-size: 0.9rem;
        padding: 0.4rem 0;
    }
}

/* Flag styling */
.country-flag-emoji {
    margin-right: 0.25rem;
    font-size: 1em;
    vertical-align: middle;
}

.country-flag {
    width: 16px;
    height: 12px;
    margin-right: 0.25rem;
    vertical-align: middle;
    border-radius: 2px;
}

/* Test count badge in action buttons */
.action-badge {
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
    border-radius: 10px;
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.25rem;
    min-width: 1.5rem;
    text-align: center;
}

/* Test Status Button Colors */
.test-status-untested {
    /* No special styling - uses default button styling */
}

.test-status-none {
    background-color: #e53e3e !important; /* Red - all tests failed (including single test) */
    color: white !important;
    border-color: #e53e3e !important;
}

.test-status-none:hover {
    background-color: #c53030 !important;
    border-color: #c53030 !important;
}

.test-status-some {
    background-color: #d69e2e !important; /* Yellow - some tests pass */
    color: white !important;
    border-color: #d69e2e !important;
}

.test-status-some:hover {
    background-color: #b7791f !important;
    border-color: #b7791f !important;
}

.test-status-all {
    background-color: #38a169 !important; /* Green - all tests pass */
    color: white !important;
    border-color: #38a169 !important;
}

.test-status-all:hover {
    background-color: #2f855a !important;
    border-color: #2f855a !important;
}