/* ============================================================================
   Aruba PQC TLS Demo - Modern Stylesheet
   Post-Quantum Cryptography Demonstrator
   ============================================================================ */

/* ===== ROOT VARIABLES ===== */
:root {
    /* Colors - Modern Palette */
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary: #8b5cf6;
    --secondary-dark: #7c3aed;
    --accent: #10b981;
    --accent-orange: #f59e0b;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;

    /* Quantum Theme Colors */
    --quantum-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --quantum-glow: rgba(102, 126, 234, 0.3);

    /* Neutrals */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;

    /* Text */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;

    /* Borders */
    --border-color: #334155;
    --border-light: #475569;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-quantum: 0 0 30px rgba(102, 126, 234, 0.3);

    /* Spacing */
    --spacing-unit: 8px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;
    --transition-slow: 400ms ease-in-out;

    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

/* ===== BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
}

/* ===== LAYOUT ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
}

/* ===== HEADER ===== */
.header {
    background: var(--bg-secondary);
    padding: 2rem 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 3rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.logo-text h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    background: var(--quantum-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text p {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin: 0;
}

.header-badge {
    display: flex;
    gap: 0.5rem;
}

.badge-quantum {
    padding: 0.5rem 1rem;
    background: var(--quantum-gradient);
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 0.875rem;
    box-shadow: var(--shadow-quantum);
    animation: glow 2s infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px var(--quantum-glow); }
    50% { box-shadow: 0 0 40px var(--quantum-glow); }
}

/* ===== MAIN CONTENT ===== */
.main-content {
    padding: 3rem 0;
    min-height: calc(100vh - 200px);
}

/* ===== CONFIG PANEL ===== */
.config-panel {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.config-panel h2 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.config-item label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

.config-item input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    transition: all var(--transition-base);
}

.config-item input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== ALGORITHM SELECTOR ===== */
.algorithm-selector {
    margin: 2rem 0;
}

.algorithm-selector h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.algorithm-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.algorithm-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

/* Add extra top padding for cards with recommended badge */
.algorithm-card.recommended {
    padding-top: 3rem;
}

.algorithm-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary);
    transform: scaleX(0);
    transition: transform var(--transition-base);
}

.algorithm-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.algorithm-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    box-shadow: var(--shadow-quantum);
}

.algorithm-card.selected::before {
    transform: scaleX(1);
}

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

.algorithm-icon {
    font-size: 2rem;
}

.algorithm-type {
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.algorithm-card h4 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
}

.algorithm-description {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.algorithm-features {
    list-style: none;
    margin-bottom: 1rem;
}

.algorithm-features li {
    padding: 0.25rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.algorithm-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent);
}

.recommended-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    background: var(--accent-orange);
    color: var(--bg-primary);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.75rem;
    box-shadow: var(--shadow-md);
}

/* ===== BUTTONS ===== */
.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: var(--font-sans);
    width: 100%;
}

.btn-primary {
    background: var(--quantum-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), var(--shadow-quantum);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}

.btn-icon {
    font-size: 1.25rem;
}

/* ===== ANIMATION SECTION ===== */
.animation-section {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.animation-section h2 {
    text-align: center;
    margin-bottom: 2rem;
}

.handshake-visualization {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    min-height: 400px;
    align-items: center;
}

@media (max-width: 968px) {
    .handshake-visualization {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .communication-channel {
        order: 2;
        transform: rotate(90deg);
        margin: 2rem 0;
    }
}

.entity {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-color);
}

.entity-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.entity-label {
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--primary-light);
}

.entity-address {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.communication-channel {
    position: relative;
    height: 400px;
}

.channel-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom,
        var(--border-color) 0%,
        var(--primary) 50%,
        var(--border-color) 100%);
    transform: translateX(-50%);
}

.packets-container {
    position: relative;
    height: 100%;
}

/* Packet Animation */
.packet {
    position: absolute;
    left: 50%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--primary);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow-quantum);
    animation: packet-glow 1s infinite;
}

@keyframes packet-glow {
    0%, 100% { box-shadow: 0 0 10px var(--quantum-glow); }
    50% { box-shadow: 0 0 20px var(--quantum-glow); }
}

.packet.client-to-server {
    transform: translateX(-50%);
    animation: move-down 1s ease-in-out forwards;
}

.packet.server-to-client {
    transform: translateX(-50%);
    animation: move-up 1s ease-in-out forwards;
}

@keyframes move-down {
    from { top: 0%; opacity: 0; }
    to { top: 100%; opacity: 1; }
}

@keyframes move-up {
    from { top: 100%; opacity: 0; }
    to { top: 0%; opacity: 1; }
}

/* ===== STEP DETAILS ===== */
.step-details {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary);
}

.step-details h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-light);
}

.step-details p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.step-details .step-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    font-size: 0.875rem;
    font-family: var(--font-mono);
}

.step-meta span {
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
}

/* ===== PROGRESS BAR ===== */
.progress-container {
    margin-top: 2rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--quantum-gradient);
    border-radius: var(--radius-lg);
    transition: width var(--transition-base);
    box-shadow: 0 0 10px var(--quantum-glow);
}

.progress-text {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* ===== RESULTS SECTION ===== */
.results-section {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.results-section h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: transform var(--transition-base);
}

.summary-card:hover {
    transform: translateY(-2px);
}

.summary-icon {
    font-size: 2rem;
}

.summary-label {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin-bottom: 0.25rem;
}

.summary-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--primary-light);
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
}

.tab-button {
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
}

.tab-button:hover {
    color: var(--text-secondary);
}

.tab-button.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

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

/* ===== CERTIFICATES ===== */
.certificates-container {
    display: grid;
    gap: 1.5rem;
}

.certificate-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border-left: 4px solid var(--accent);
}

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

.certificate-level {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

.certificate-algorithm {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--primary-light);
}

.certificate-details {
    display: grid;
    gap: 0.75rem;
}

.certificate-field {
    display: flex;
    gap: 1rem;
}

.certificate-field-label {
    min-width: 120px;
    color: var(--text-tertiary);
    font-weight: 600;
    font-size: 0.875rem;
}

.certificate-field-value {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    word-break: break-all;
}

.certificate-sans {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.san-badge {
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--accent);
}

/* ===== STEPS TIMELINE ===== */
.steps-timeline {
    position: relative;
    padding-left: 2rem;
}

.steps-timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-step {
    position: relative;
    padding-bottom: 2rem;
}

.timeline-step::before {
    content: '';
    position: absolute;
    left: -2.5rem;
    top: 0.5rem;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--bg-card);
}

.timeline-step.client-to-server::before {
    background: var(--accent);
}

.timeline-step.server-to-client::before {
    background: var(--secondary);
}

.timeline-content {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.timeline-phase {
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--primary-light);
}

.timeline-direction {
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.timeline-description {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.timeline-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-tertiary);
}

/* ===== STATISTICS ===== */
.statistics-container {
    display: grid;
    gap: 1.5rem;
}

.stat-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.stat-card h3 {
    margin-bottom: 1rem;
    color: var(--primary-light);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.stat-label {
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

.stat-value {
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.stat-comparison {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent-orange);
}

.stat-comparison p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
}

.footer p {
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
}

.footer-tech {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ===== UTILITY CLASSES ===== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-1 { margin-bottom: calc(var(--spacing-unit) * 1); }
.mb-2 { margin-bottom: calc(var(--spacing-unit) * 2); }
.mb-3 { margin-bottom: calc(var(--spacing-unit) * 3); }
.mb-4 { margin-bottom: calc(var(--spacing-unit) * 4); }

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
    .container {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .config-grid {
        grid-template-columns: 1fr;
    }

    .algorithm-cards {
        grid-template-columns: 1fr;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .certificate-field {
        flex-direction: column;
        gap: 0.25rem;
    }

    .certificate-field-label {
        min-width: auto;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes slideInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.animate-in {
    animation: slideInUp 0.5s ease-out;
}

/* ===== PRINT STYLES ===== */
@media print {
    .header, .footer, .config-panel, .btn-primary, .btn-secondary {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    .results-section {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
