/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    animation: backgroundShift 20s ease-in-out infinite;
}

@keyframes backgroundShift {
    0%, 100% { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
    50% { background: linear-gradient(135deg, #764ba2 0%, #667eea 100%); }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    animation: slideIn 0.8s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header styles */
.header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 3rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: float 20s linear infinite;
}

@keyframes float {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
}

.header .description {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Card styles */
.card {
    background: white;
    margin: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: fadeInUp 0.6s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }

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

.card h3 {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 1.5rem 2rem;
    margin: 0;
    font-size: 1.3rem;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

.hidden {
    display: none !important;
}

/* Characteristic Button Styles - Modern Card Design */
.characteristic-button {
    /* Remove default button styles */
    border: none;
    outline: none;
    background: none;
    
    /* Modern card-like appearance */
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 1.25rem;
    margin: 0;
    
    /* Typography */
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
    text-align: left;
    text-transform: capitalize;
    
    /* Visual design */
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    
    /* Interactions */
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Hover effects */
.characteristic-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #d1d5db;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

/* Selected state */
.characteristic-button.selected {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: #3b82f6;
    color: #1e40af;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
    transform: translateY(-1px);
}

.characteristic-button.selected:hover {
    background: linear-gradient(135deg, #bfdbfe 0%, #93c5fd 100%);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

/* Disabled state */
.characteristic-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border-color: #e5e7eb;
    color: #9ca3af;
}

.characteristic-button:disabled:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border-color: #e5e7eb;
}

/* Selection order indicator */
.selection-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.75rem;
    animation: bounceIn 0.3s ease-out;
    flex-shrink: 0;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Active/pressed state */
.characteristic-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Focus states for accessibility */
.characteristic-button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.characteristic-button:focus:not(:focus-visible) {
    outline: none;
}

/* Shimmer effect on hover */
.characteristic-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
    pointer-events: none;
}

.characteristic-button:hover:not(:disabled)::before {
    left: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .characteristic-button {
        padding: 0.875rem 1rem;
        font-size: 0.85rem;
    }
    
    .selection-order {
        min-width: 20px;
        height: 20px;
        font-size: 0.7rem;
        margin-left: 0.5rem;
    }
}

@media (max-width: 480px) {
    .characteristic-button {
        padding: 0.75rem 0.875rem;
        font-size: 0.8rem;
    }
    
    .selection-order {
        min-width: 18px;
        height: 18px;
        font-size: 0.65rem;
        margin-left: 0.4rem;
    }
}

/* Totals card styles */
.totals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    padding: 2rem;
}

.total-item {
    text-align: center;
    padding: 1.5rem 1rem;
    border-radius: 8px;
    background: #f8fafc;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.total-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.total-item:hover::before {
    left: 100%;
}

.total-item.best {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-color: #059669;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3); }
    to { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5); }
}

.total-item h4 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    text-transform: capitalize;
    font-weight: 600;
}

.total-score {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    transition: transform 0.3s ease;
}

.total-item:hover .total-score {
    transform: scale(1.1);
}

.total-max {
    font-size: 0.8rem;
    opacity: 0.7;
}

.selected-info {
    padding: 1rem 2rem;
    background: #f1f5f9;
    border-top: 1px solid #e5e7eb;
    font-style: italic;
    color: #64748b;
}

/* Table styles */
.main-table-card {
    margin: 2rem;
    padding: 0;
}

.table-container {
    overflow-x: auto;
}

#comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: fixed; /* This ensures consistent column widths */
}

.table-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
}

.table-header th {
    padding: 0;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    border-right: 1px solid #475569;
}

.table-header th:last-child {
    border-right: none;
}

.characteristics-header {
    width: 220px; /* Fixed width for characteristics column */
    min-width: 220px;
    padding: 1rem 1.5rem;
    vertical-align: middle;
    font-size: 1rem;
    font-weight: 700;
}

/* Architecture headers container */
#architecture-headers {
    width: calc(100% - 220px); /* Take remaining space after characteristics column */
    padding: 5px;
}

.architecture-headers {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0;
    width: 100%;
    height: 100%;
    animation: fadeInHeaders 0.8s ease-out;
}

@keyframes fadeInHeaders {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.architecture-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.75rem;
    color: white;
    min-height: 120px; /* Increased height for better image display */
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer; /* Add cursor pointer for interactivity */
}

.architecture-header:hover {
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.architecture-header:last-child {
    border-right: none;
}

.architecture-header.best {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: inset 0 0 0 2px #34d399, 0 4px 12px rgba(16, 185, 129, 0.3);
    animation: highlight 1s ease-in-out;
    z-index: 2; /* Ensure best headers are above others */
}

.architecture-header.best:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: inset 0 0 0 2px #34d399, 0 6px 15px rgba(16, 185, 129, 0.4);
}

/* Add a subtle pattern to the header background */
.architecture-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.5;
    pointer-events: none;
}

/* Updated architecture icon to display SVG images */
.architecture-icon {
    width: 50px; /* Larger size for better visibility */
    height: 32px;
    margin-bottom: 0.75rem;
    opacity: 0.95;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 4px;
}

/* Architecture-specific image backgrounds */
.architecture-header[data-architecture="layered"] .architecture-icon {
    background-image: url('/images/architectures/layered.svg');
}

/* Use contains operator for modular monolith */
.architecture-header[data-architecture*="modular"] .architecture-icon {
    background-image: url('/images/architectures/modular-monolith.svg');
}

.architecture-header[data-architecture="microkernel"] .architecture-icon {
    background-image: url('/images/architectures/microkernel.svg');
}

.architecture-header[data-architecture="microservices"] .architecture-icon {
    background-image: url('/images/architectures/microservices.svg');
}

.architecture-header[data-architecture*="service-based"] .architecture-icon {
    background-image: url('/images/architectures/service-based.svg');
}

.architecture-header[data-architecture*="service-oriented"] .architecture-icon {
    background-image: url('/images/architectures/service-oriented.svg');
}

.architecture-header[data-architecture*="event-driven"] .architecture-icon {
    background-image: url('/images/architectures/event-driven.svg');
}

.architecture-header[data-architecture*="space-based"] .architecture-icon {
    background-image: url('/images/architectures/space-based.svg');
}

.architecture-header:hover .architecture-icon {
    transform: scale(1.1);
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.2);
}

.architecture-name {
    font-size: 0.85rem; /* Slightly larger text */
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    text-transform: capitalize;
    word-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Better handling of specific architecture names */
.architecture-name {
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Special handling for longer names */
.architecture-header[data-architecture*="monolith"] .architecture-name,
.architecture-header[data-architecture*="microservices"] .architecture-name,
.architecture-header[data-architecture*="service-based"] .architecture-name,
.architecture-header[data-architecture*="service-oriented"] .architecture-name {
    font-size: 0.8rem;
    line-height: 1.2;
}

/* Table body styles */
tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: #f8fafc;
    transform: translateX(2px);
}

tbody tr.selected {
    background: linear-gradient(90deg, #dbeafe 0%, #e0f2fe 100%);
    border-left: 4px solid #3b82f6;
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-10px);
        opacity: 0.5;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.characteristic-cell {
    width: 220px; /* Match header width */
    padding: 0;
    border-right: 1px solid #e5e7eb;
    background: #f8fafc;
}

/* Rating cells */
.rating-cell {
    padding: 1rem 0.75rem; /* Better padding to match header */
    text-align: center;
    border-right: 1px solid #e5e7eb;
    transition: all 0.3s ease;
    width: calc((100% - 220px) / 8); /* Equal width distribution */
}

.rating-cell:last-child {
    border-right: none;
}

.rating-cell.highlighted {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    box-shadow: inset 0 0 0 1px #f59e0b;
    animation: highlightPulse 1s ease-in-out infinite alternate;
}

@keyframes highlightPulse {
    from { box-shadow: inset 0 0 0 1px #f59e0b, 0 0 5px rgba(245, 158, 11, 0.3); }
    to { box-shadow: inset 0 0 0 1px #f59e0b, 0 0 15px rgba(245, 158, 11, 0.5); }
}

/* Stars */
.stars {
    display: flex;
    justify-content: center;
    gap: 2px;
}

.star {
    width: 16px;
    height: 16px;
    transition: all 0.2s ease;
}

.star.filled {
    fill: #fbbf24;
    filter: drop-shadow(0 1px 2px rgba(251, 191, 36, 0.3));
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

.star.empty {
    fill: #d1d5db;
}

.rating-cell:hover .star.filled {
    fill: #f59e0b;
    transform: scale(1.1) rotate(10deg);
}

.rating-cell:hover .star.empty {
    fill: #9ca3af;
    transform: scale(1.05);
}

/* Best architectures card */
.best-architectures {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 2rem;
    justify-content: center;
}

.best-architecture-tag {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    transition: all 0.3s ease;
    text-transform: capitalize;
    position: relative;
    overflow: hidden;
}

.best-architecture-tag::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.best-architecture-tag:hover::before {
    left: 100%;
}

.best-architecture-tag:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Footer */
.footer {
    background: #f8fafc;
    padding: 2rem;
    text-align: center;
    color: #64748b;
    border-top: 1px solid #e5e7eb;
}

.footer p {
    margin: 0;
    font-size: 0.9rem;
}

/* Responsive design */
@media (max-width: 1200px) {
    .characteristics-header {
        width: 200px;
        min-width: 200px;
        font-size: 0.9rem;
    }
    
    #architecture-headers {
        width: calc(100% - 200px);
    }
    
    .characteristic-cell {
        width: 200px;
    }
    
    .rating-cell {
        width: calc((100% - 200px) / 8);
        padding: 0.75rem 0.5rem;
    }
    
    .architecture-header {
        padding: 0.75rem 0.5rem;
        min-height: 100px;
    }
    
    .architecture-icon {
        width: 45px;
        height: 28px;
    }
    
    .architecture-name {
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .characteristics-header {
        width: 160px;
        min-width: 160px;
        padding: 1rem;
        font-size: 0.85rem;
    }
    
    #architecture-headers {
        width: calc(100% - 160px);
    }
    
    .characteristic-cell {
        width: 160px;
    }
    
    .rating-cell {
        width: calc((100% - 160px) / 8);
        padding: 0.5rem 0.25rem;
    }
    
    .architecture-headers {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .architecture-header {
        padding: 0.75rem 0.25rem;
        min-height: 90px;
    }
    
    .architecture-icon {
        width: 40px;
        height: 25px;
        margin-bottom: 0.5rem;
    }
    
    .architecture-name {
        font-size: 0.7rem;
        line-height: 1.2;
    }
}

@media (max-width: 480px) {
    .characteristics-header {
        width: 140px;
        min-width: 140px;
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
    
    #architecture-headers {
        width: calc(100% - 140px);
    }
    
    .characteristic-cell {
        width: 140px;
    }
    
    .rating-cell {
        width: calc((100% - 140px) / 4); /* Show 4 columns on mobile */
        padding: 0.5rem 0.25rem;
    }
    
    .architecture-headers {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .architecture-header {
        padding: 0.5rem 0.25rem;
        min-height: 80px;
    }
    
    .architecture-icon {
        width: 35px;
        height: 22px;
        margin-bottom: 0.4rem;
    }
    
    .architecture-name {
        font-size: 0.65rem;
        line-height: 1.1;
    }
}

/* Loading and error states */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    font-size: 1.1rem;
    color: #64748b;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 1rem;
}

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

.error {
    background: #fee2e2;
    color: #dc2626;
    padding: 2rem;
    border-radius: 8px;
    margin: 2rem;
    text-align: center;
    border: 1px solid #fecaca;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.error h2 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

/* Print styles */
@media print {
    body {
        background: white;
        padding: 0;
        animation: none;
    }
    
    .container {
        box-shadow: none;
        border-radius: 0;
        animation: none;
    }
    
    .header {
        background: #f8fafc !important;
        color: #1e293b !important;
    }
    
    .header::before {
        display: none;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #e5e7eb;
        break-inside: avoid;
        animation: none;
    }
    
    .characteristic-button {
        background: white !important;
        color: black !important;
    }
    
    .star.filled {
        fill: black !important;
    }
    
    * {
        animation: none !important;
        transition: none !important;
    }
}}