/* Tool Hero Section - Required by tool-page-structure.mdc */
.tool-hero {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.hero-text {
    flex: 1;
    min-width: 260px;
}

.hero-text h1 {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0;
}

.hero-subtitle {
    font-size: 18px;
    color: var(--text-muted);
    max-width: 720px;
    margin-bottom: 1rem;
    margin-top: 0;
}

@media (max-width: 767px) {
    .hero-text h1 {
        font-size: clamp(1.75rem, 5vw, 2.5rem);
    }
    
    .hero-subtitle {
        font-size: clamp(1rem, 3vw, 1.125rem);
    }
}

/* JWT Decoder Interface */
.jwt-decoder-interface {
    margin-bottom: 2rem;
}

.jwt-main-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.card-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 600px;
}

/* Input Section (Left) */
.input-section {
    border-right: 1px solid #e5e7eb;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: #fafbfc;
}

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

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.validation-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: #d1fae5;
    color: #065f46;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
}

.validation-badge .badge-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

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

.action-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #3b82f6;
    background: transparent;
    border: 1px solid #3b82f6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: #3b82f6;
    color: #ffffff;
}

/* Input Container */
.input-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.textarea-wrapper {
    position: relative;
}

.jwt-input {
    width: 100%;
    min-height: 350px;
    padding: 1rem;
    font-size: 0.875rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    line-height: 1.6;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
    color: #111827;
    resize: vertical;
    transition: all 0.2s ease;
}

.jwt-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.jwt-input::placeholder {
    color: #9ca3af;
}

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

.control-group {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.control-buttons {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

.control-btn .btn-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

/* Verification Section */
.verification-section {
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.verification-header {
    margin-bottom: 1rem;
}

.verification-title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.25rem 0;
}

.verification-subtitle {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
}

.secret-input-wrapper {
    margin-bottom: 1rem;
}

.secret-input-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.secret-input {
    flex: 1;
    padding: 0.75rem;
    font-size: 0.875rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    background: #ffffff;
    color: #111827;
    transition: all 0.2s ease;
}

.secret-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.secret-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secret-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.secret-btn .btn-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.secret-validation {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #d1fae5;
    color: #065f46;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
}

.secret-validation .validation-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

.encoding-format {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.format-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.format-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    color: #111827;
    cursor: pointer;
    transition: all 0.2s ease;
}

.format-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.signature-status {
    margin-top: 1rem;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-badge.verified {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.invalid {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge .badge-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

/* Results Section (Right) */
.results-section {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: #ffffff;
    overflow-y: auto;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.results-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.decoded-content {
    flex: 1;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
    color: #9ca3af;
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 1.5;
}

.empty-text {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
}

/* Decoded Parts */
.decoded-part {
    margin-bottom: 2rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.part-header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 1rem;
}

.part-title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
    flex: 1;
    min-width: 0;
}

.part-actions {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
}

.view-toggle {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
    z-index: 1;
}

.view-toggle:first-child {
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
    border-right: none;
}

.view-toggle:last-child {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
    border-left: none;
}

.view-toggle:not(:first-child):not(:last-child) {
    border-left: none;
    border-right: none;
}

.view-toggle.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
    z-index: 2;
}

.view-toggle.active + .view-toggle {
    border-left-color: #3b82f6;
}

.view-toggle:hover:not(.active) {
    background: #f9fafb;
    z-index: 2;
}

.copy-part-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 0.5rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.copy-part-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.copy-part-btn .btn-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.part-content-wrapper {
    padding: 1.25rem;
    background: #ffffff;
    overflow-x: auto;
    overflow-y: visible;
    min-height: 100px;
}

.json-view {
    display: block;
}

.table-view {
    display: none;
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
}

.table-view.active {
    display: block;
    width: 100%;
}

.json-output {
    margin: 0;
    font-size: 0.8125rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    line-height: 1.6;
    color: #111827;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Claims Table */
.table-view {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
}

.claims-table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    table-layout: auto;
    display: table;
}

.claims-table thead {
    background: #f9fafb;
    position: sticky;
    top: 0;
    z-index: 10;
}

.claims-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.claims-table th:first-child {
    min-width: 120px;
    width: 15%;
}

.claims-table th:nth-child(2) {
    min-width: 200px;
    width: 35%;
}

.claims-table th:nth-child(3) {
    min-width: 250px;
    width: 50%;
}

/* Payload table header specific */
#payloadTable th:first-child {
    min-width: 140px;
    width: 18%;
}

#payloadTable th:nth-child(2) {
    min-width: 200px;
    width: 32%;
}

#payloadTable th:nth-child(3) {
    min-width: 250px;
    width: 50%;
}

.claims-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    color: #111827;
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.claims-table tbody tr:hover {
    background: #f9fafb;
}

.claims-table tbody tr:last-child td {
    border-bottom: none;
}

.claims-table td:first-child {
    font-weight: 500;
    color: #6b7280;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 0.8125rem;
    white-space: nowrap;
    min-width: 120px;
    width: 15%;
}

.claims-table td:nth-child(2) {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: none;
    width: 35%;
}

.claims-table td:nth-child(2) div {
    word-break: break-word;
    overflow-wrap: break-word;
}

.claims-table td:nth-child(3) {
    font-size: 0.8125rem;
    color: #6b7280;
    font-style: italic;
    max-width: none;
    width: 50%;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.5;
}

/* Payload table specific styles */
#payloadTable td:first-child {
    min-width: 140px;
    width: 18%;
}

#payloadTable td:nth-child(2) {
    width: 32%;
    min-width: 200px;
}

#payloadTable td:nth-child(2) div {
    display: block;
    word-break: break-word;
    overflow-wrap: break-word;
}

#payloadTable td:nth-child(2) div:first-child {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    margin-bottom: 0.25rem;
}

#payloadTable td:nth-child(3) {
    width: 50%;
    min-width: 250px;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .card-split {
        grid-template-columns: 1fr;
    }

    .input-section {
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .results-section {
        max-height: none;
    }
}

@media (max-width: 768px) {
    .jwt-decoder-interface {
        margin-top: 1.5rem;
    }

    .input-section,
    .results-section {
        padding: 1.5rem;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions {
        width: 100%;
    }

    .action-btn {
        flex: 1;
        text-align: center;
    }

    .input-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-buttons {
        width: 100%;
        justify-content: stretch;
    }

    .control-btn {
        flex: 1;
        justify-content: center;
    }

    .secret-input-container {
        flex-direction: column;
    }

    .secret-actions {
        width: 100%;
    }

    .secret-btn {
        flex: 1;
        justify-content: center;
    }

    .encoding-format {
        flex-direction: column;
        align-items: stretch;
    }

    .format-select {
        width: 100%;
    }

    .part-header-section {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .part-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: nowrap;
    }

    .view-toggle {
        flex: 1;
        min-width: 0;
    }
    
    .part-content-wrapper {
        padding: 1rem;
        overflow-x: auto;
    }
    
    .claims-table {
        font-size: 0.8125rem;
    }
    
    .claims-table th,
    .claims-table td {
        padding: 0.5rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .input-section,
    .results-section {
        padding: 1rem;
    }

    .jwt-input {
        min-height: 150px;
        font-size: 0.8125rem;
    }

    .control-btn span,
    .secret-btn span {
        display: none;
    }

    .control-btn,
    .secret-btn {
        padding: 0.5rem;
        min-width: 40px;
        justify-content: center;
    }
}

/* Error Messages */
.error-message {
    padding: 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 1rem 0;
}

/* Accessibility */
*:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Smooth Scrolling */
.results-section {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.results-section::-webkit-scrollbar {
    width: 8px;
}

.results-section::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.results-section::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.results-section::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
