/* JSON Formatter - Fully Responsive with Day/Night Mode */

/* Import fonts */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

/* ====================== JSON FORMATTER STYLES ====================== */

.json-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    font-family: 'Poppins', sans-serif;
}

.json-wrapper {
    max-width: 1000px;
    margin: 0 auto;
}

.json-title {
    font-size: 3rem;
    font-weight: 800;
    font-family: 'Poppins', sans-serif;
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

.json-heart {
    font-size: 2.8rem;
    display: inline-block;
    animation: pulse 2s infinite;
}

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

.json-subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
    font-family: 'Poppins', sans-serif;
}

.json-card {
    background: var(--surface);
    border-radius: var(--radius, 16px);
    border: 1px solid var(--border);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

/* Tabs */
.json-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.json-tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 0.6rem 1.2rem;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.json-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.json-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Sections */
.json-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.json-section.active {
    display: block;
}

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

.json-section-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.2rem;
    color: var(--text);
    font-family: 'Poppins', sans-serif;
}

/* Input Area */
.json-input-area {
    margin-bottom: 1.5rem;
}

.json-textarea {
    width: 100%;
    min-height: 250px;
    padding: 1.2rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    transition: all 0.3s ease;
}

.json-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Action Buttons */
.json-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 1rem;
}

.json-action-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.7rem 1.4rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.json-action-btn:hover:not(:disabled) {
    background: var(--surface);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.json-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.json-action-btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.json-action-btn.primary:hover:not(:disabled) {
    background: var(--primary-light, #818cf8);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

/* Result Area */
.json-result-area {
    margin-top: 2rem;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}

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

.json-result-header h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.json-result-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.json-line-count,
.json-size-info {
    font-size: 0.9rem;
    color: var(--text-light);
    background: var(--bg);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.json-icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.json-icon-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.json-result {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.2rem;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text);
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
}

/* Error Area */
.json-error-area {
    margin-top: 1.5rem;
    padding: 1.2rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    border-radius: 12px;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.json-error-icon {
    font-size: 1.5rem;
}

.json-error-message {
    color: #ef4444;
    font-size: 0.95rem;
    line-height: 1.5;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
}

/* Validator Section */
.json-validator-result {
    margin-top: 1.5rem;
    padding: 1.2rem;
    border-radius: 12px;
}

.validator-status {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.validator-status.valid {
    color: #10b981;
}

.validator-status.invalid {
    color: #ef4444;
}

.validator-details {
    font-size: 0.95rem;
    color: var(--text-light);
    line-height: 1.5;
}

/* Converter Tabs */
.converter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.converter-tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.converter-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.converter-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.converter-content {
    display: none;
}

.converter-content.active {
    display: block;
}

/* Examples Section */
.json-examples {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.json-examples h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

.example-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.example-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 0.5rem 1.2rem;
    border-radius: 30px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.example-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-2px);
}

/* Fun Fact */
.json-funfact {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    text-align: center;
    font-weight: 600;
    margin: 2rem auto;
    max-width: 600px;
    box-shadow: var(--shadow);
    font-size: 1rem;
}

/* SEO Section */
.json-seo {
    margin: 4rem 0;
    padding: 2rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.json-seo h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text);
    font-family: 'Poppins', sans-serif;
}

.json-seo h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 1.5rem 0 1rem;
    color: var(--text);
}

.json-seo p {
    color: var(--text-light);
    line-height: 1.8;
    margin-bottom: 1rem;
}

.json-features-list {
    padding-left: 1.5rem;
    margin: 1rem 0;
}

.json-features-list li {
    color: var(--text-light);
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.json-features-list li::marker {
    color: var(--primary);
}

/* Loading Overlay */
.json-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.json-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* ====================== RESPONSIVE DESIGN ====================== */

/* Tablet Styles (768px to 1024px) */
@media screen and (max-width: 1024px) {
    .json-container {
        padding: 0 1.5rem;
        margin: 1.5rem auto;
    }

    .json-title {
        font-size: 2.5rem;
    }

    .json-heart {
        font-size: 2.3rem;
    }

    .json-card {
        padding: 1.5rem;
    }
}

/* Mobile Landscape & Tablet Portrait (481px to 768px) */
@media screen and (max-width: 768px) {
    .json-container {
        padding: 0 1rem;
        margin: 1rem auto;
    }

    .json-title {
        font-size: 2rem;
    }

    .json-heart {
        font-size: 1.8rem;
    }

    .json-subtitle {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }

    .json-card {
        padding: 1.2rem;
    }

    .json-tabs {
        gap: 0.4rem;
    }

    .json-tab {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .json-section-title {
        font-size: 1.1rem;
    }

    .json-textarea {
        min-height: 180px;
        padding: 1rem;
        font-size: 0.85rem;
    }

    .json-action-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.85rem;
    }

    .json-result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .json-result-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .json-line-count,
    .json-size-info {
        font-size: 0.8rem;
    }

    .json-result {
        padding: 1rem;
        font-size: 0.8rem;
        max-height: 300px;
    }

    .converter-tabs {
        gap: 0.4rem;
    }

    .converter-tab {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .example-btn {
        padding: 0.4rem 1rem;
        font-size: 0.8rem;
    }

    .json-funfact {
        font-size: 0.85rem;
        padding: 0.8rem 1.5rem;
    }

    .json-seo {
        padding: 1.5rem;
    }

    .json-seo h2 {
        font-size: 1.5rem;
    }

    .json-seo h3 {
        font-size: 1.1rem;
    }

    .json-seo p,
    .json-features-list li {
        font-size: 0.9rem;
    }
}

/* Mobile Portrait (up to 480px) */
@media screen and (max-width: 480px) {
    .json-container {
        padding: 0 0.75rem;
        margin: 0.75rem auto;
    }

    .json-title {
        font-size: 1.5rem;
    }

    .json-heart {
        font-size: 1.3rem;
    }

    .json-subtitle {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }

    .json-card {
        padding: 1rem;
        border-radius: 12px;
    }

    .json-tabs {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
        border-bottom: none;
        padding-bottom: 0;
    }

    .json-tab {
        width: 100%;
        text-align: center;
        padding: 0.6rem;
    }

    .json-section-title {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .json-textarea {
        min-height: 150px;
        padding: 0.8rem;
        font-size: 0.8rem;
    }

    /* Make action buttons stack in 2 columns */
    .json-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .json-action-btn {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
        width: 100%;
        justify-content: center;
    }

    .json-result-header h4 {
        font-size: 0.95rem;
    }

    .json-result-actions {
        gap: 0.6rem;
    }

    .json-line-count,
    .json-size-info {
        font-size: 0.7rem;
        padding: 0.2rem 0.6rem;
    }

    .json-icon-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .json-result {
        padding: 0.8rem;
        font-size: 0.75rem;
        max-height: 250px;
    }

    .json-error-area {
        padding: 0.8rem;
    }

    .json-error-icon {
        font-size: 1.2rem;
    }

    .json-error-message {
        font-size: 0.8rem;
    }

    .validator-status {
        font-size: 1rem;
    }

    .validator-details {
        font-size: 0.8rem;
    }

    .converter-tabs {
        width: 100%;
    }

    .converter-tab {
        flex: 1;
        text-align: center;
    }

    .example-buttons {
        gap: 0.6rem;
    }

    .example-btn {
        padding: 0.35rem 0.8rem;
        font-size: 0.75rem;
    }

    .json-funfact {
        font-size: 0.75rem;
        padding: 0.6rem 1rem;
        border-radius: 30px;
    }

    .json-seo {
        padding: 1rem;
    }

    .json-seo h2 {
        font-size: 1.2rem;
    }

    .json-seo h3 {
        font-size: 1rem;
    }

    .json-seo p,
    .json-features-list li {
        font-size: 0.85rem;
    }

    .json-features-list {
        padding-left: 1.2rem;
    }
}

/* Extra Small Devices (up to 360px) */
@media screen and (max-width: 360px) {
    .json-title {
        font-size: 1.3rem;
    }

    .json-heart {
        font-size: 1.1rem;
    }

    .json-actions {
        grid-template-columns: 1fr;
    }

    .json-result-actions {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    .json-line-count,
    .json-size-info {
        width: 100%;
        text-align: center;
    }

    .json-icon-btn {
        width: 100%;
    }
}

/* Touch-friendly improvements for mobile devices */
@media (hover: none) and (pointer: coarse) {
    .json-tab,
    .json-action-btn,
    .example-btn,
    .converter-tab,
    .json-icon-btn {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .json-action-btn:active,
    .example-btn:active,
    .json-icon-btn:active {
        transform: scale(0.98);
    }
}

/* Loading overlay responsiveness */
@media screen and (max-width: 768px) {
    .json-spinner {
        width: 40px;
        height: 40px;
    }

    .json-loading p {
        font-size: 0.9rem;
    }
}

/* Print styles */
@media print {
    .json-tabs,
    .json-actions,
    .json-result-actions,
    .json-examples,
    .json-funfact {
        display: none;
    }

    .json-container {
        padding: 0;
        margin: 0;
    }

    .json-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Smooth transitions */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

/* Dark mode specific adjustments */
@media (prefers-color-scheme: dark) {
    .json-card {
        background: var(--surface);
    }
}

/* Scrollbar styling */
.json-textarea::-webkit-scrollbar,
.json-result::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.json-textarea::-webkit-scrollbar-track,
.json-result::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 4px;
}

.json-textarea::-webkit-scrollbar-thumb,
.json-result::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.json-textarea::-webkit-scrollbar-thumb:hover,
.json-result::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light, #818cf8);
}