/* Re-using variables from dashboard.css for consistency */
:root {
    --primary: #4361ee;
    --primary-dark: #3a0ca3;
    --primary-light: #4895ef;
    --accent: #4cc9f0;
    --success: #2ecc71;
    --warning: #f39c12;
    --error: #e74c3c;
    
    --text-primary: #1a1d21;
    --text-secondary: #6c757d;
    --text-muted: #8b8f94;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    
    --border-color: #e2e8f0;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
    
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    
    --transition: all 0.3s ease;
    --header-height: 60px;
}

/* Dark mode variables */
body.dark-mode {
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --bg-tertiary: #4a5568;
    
    --border-color: #4a5568;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Global box-sizing and overflow control */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    overflow-x: hidden;
}

/* Navigation Bar Styles */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    max-width: 100vw;
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    overflow: hidden;
}

.mobile-menu-toggle {
    font-size: 1.2rem;
    padding: 0.5rem;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    min-width: 36px;
    min-height: 36px;
    transition: var(--transition);
}

.mobile-menu-toggle:hover {
    color: var(--primary);
    transform: scale(1.1);
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mobile-logo i {
    font-size: 1.2rem;
}

.mobile-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.content-header {
    display: none;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 250px;
    height: calc(100vh - var(--header-height));
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    transition: width 0.3s ease;
    z-index: 999;
    overflow-y: auto;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-header .logo-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .menu-text,
.sidebar.collapsed .sidebar-footer .theme-btn span,
.sidebar.collapsed .footer-links span {
    display: none;
}

.sidebar.collapsed .menu-icon {
    margin: 0 auto;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 998;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    margin-left: 250px;
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 60px;
}

/* Tool Page Layout */
.tool-page {
    padding: 0.5rem;
    background-color: var(--bg-secondary);
    min-height: calc(100vh - var(--header-height));
    width: 100%;
    max-width: 100%;
    margin-top: var(--header-height);
    overflow-x: hidden;
}

/* Hero Section */
.tool-hero {
    position: relative;
    padding: 1.5rem 0.5rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 70%, var(--accent) 100%);
    color: white;
    box-shadow: var(--shadow-lg);
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" opacity="0.1"%3E%3Cpath fill="%23ffffff" d="M100 0L200 100L100 200L0 100z"/%3E%3C/svg%3E');
    background-size: 40px;
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 100%;
    padding: 0 0.25rem;
}

.tool-hero h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: fadeInDown 0.8s ease-out;
}

.tool-hero p {
    font-size: 1rem;
    line-height: 1.4;
    opacity: 0.9;
    animation: fadeIn 1s ease-out 0.2s both;
}

/* Tool Content */
.tool-content {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 0.25rem;
    width: 100%;
}

/* Back Button */
.back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--primary);
    text-decoration: none;
    margin-bottom: 0.75rem;
    transition: var(--transition);
}

.back-button:hover {
    color: var(--primary-dark);
    transform: translateX(-4px);
}

/* Converter Card */
.converter-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.converter-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(145deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.converter-card::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;
}

.converter-card:hover::before {
    left: 100%;
}

.card-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.converter-card:hover .card-icon {
    transform: scale(1.1) rotate(5deg);
}

.card-content {
    flex: 1;
    overflow: hidden;
}

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

.converter-header h2 {
    font-size: 1.2rem;
    color: var(--text-primary);
    font-weight: 600;
}

.status-message {
    padding: 0.4rem 0.6rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
}

.status-message.info {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.status-message.success {
    background: var(--success);
    color: white;
}

.status-message.error {
    background: var(--error);
    color: white;
}

/* Input Group */
.input-group {
    margin-bottom: 0.75rem;
}

.input-group label {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
    font-weight: 500;
    display: block;
}

.input-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: var(--transition);
    resize: vertical;
    font-family: monospace;
    min-height: 100px;
}

.input-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.option-group {
    display: flex;
    flex-direction: column;
}

.option-group label {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    appearance: none;
    transition: var(--transition);
}

.select-wrapper select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

.select-wrapper i {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Tool Actions */
.tool-actions-bottom {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.tool-btn {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    min-height: 36px;
}

.tool-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(67, 97, 238, 0.3);
}

.tool-btn.secondary {
    background: linear-gradient(135deg, var(--text-secondary) 0%, var(--text-muted) 100%);
    color: var(--bg-primary);
}

.tool-btn.secondary:hover {
    box-shadow: 0 6px 15px rgba(108, 117, 125, 0.3);
}

.tool-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* Result Section */
.result-section {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1rem;
}

.result-header {
    margin-bottom: 0.5rem;
}

.result-header h3 {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.json-preview {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.json-preview pre {
    width: 100%;
    max-width: 100%;
    max-height: 300px;
    overflow: auto;
    background: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.json-preview code {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.json-actions {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    gap: 0.5rem;
}

.json-actions .tool-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    min-height: 36px;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.info-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    position: relative;
    overflow: hidden;
}

.info-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(145deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.info-card::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;
}

.info-card:hover::before {
    left: 100%;
}

.info-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    transition: transform 0.3s ease;
}

.info-card:hover .info-icon {
    transform: scale(1.1) rotate(5deg);
}

.info-card h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.info-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* Error Notification */
.error-notification {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--error);
    color: white;
    padding: 0.75rem;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
}

.error-notification .error-close {
    background: none;
    border: none;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    min-width: 36px;
    min-height: 36px;
    transition: var(--transition);
}

.error-notification .error-close:hover {
    color: var(--primary-light);
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Responsive Design */
@media (min-width: 1025px) {
    .mobile-header {
        display: none;
    }

    .content-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
        width: 100%;
        max-width: 100%;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
    }

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

    .menu-toggle {
        font-size: 1.2rem;
        padding: 0.5rem;
        background: none;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        min-width: 36px;
        min-height: 36px;
        transition: var(--transition);
    }

    .menu-toggle:hover {
        color: var(--primary);
        transform: scale(1.1);
    }

    .content-header h2 {
        font-size: 1.2rem;
        font-weight: 600;
        color: var(--text-primary);
    }

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

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

    .action-btn {
        padding: 0.5rem;
        background: none;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        position: relative;
        min-width: 36px;
        min-height: 36px;
        transition: var(--transition);
    }

    .action-btn:hover {
        color: var(--primary);
        transform: scale(1.1);
    }

    .notification-badge {
        position: absolute;
        top: 0;
        right: 0;
        background: var(--error);
        color: white;
        border-radius: 50%;
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

    .user-menu .user-avatar-sm img {
        width: 36px;
        height: 36px;
        border-radius: 50%;
    }

    .sidebar {
        top: var(--header-height);
        left: 0;
        width: 250px;
    }

    .sidebar.collapsed {
        width: 60px;
    }

    .main-content {
        margin-left: 250px;
    }

    .main-content.expanded {
        margin-left: 60px;
    }

    .tool-page {
        padding: 1rem;
    }

    .tool-hero {
        padding: 2rem 1rem;
    }

    .tool-hero h1 {
        font-size: 2rem;
    }

    .tool-hero p {
        font-size: 1.1rem;
    }

    .converter-card {
        padding: 1rem;
    }

    .converter-header h2 {
        font-size: 1.3rem;
    }

    .input-group {
        margin-bottom: 1rem;
    }

    .input-group label {
        font-size: 0.9rem;
    }

    .input-group textarea {
        padding: 0.75rem;
        font-size: 1rem;
    }

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

    .option-group label {
        font-size: 0.9rem;
    }

    .select-wrapper select {
        padding: 0.75rem;
        font-size: 1rem;
    }

    .select-wrapper i {
        font-size: 1rem;
    }

    .tool-actions-bottom {
        gap: 0.75rem;
    }

    .result-section {
        padding: 1rem;
    }

    .result-header h3 {
        font-size: 1.1rem;
    }

    .json-preview pre {
        padding: 1rem;
        font-size: 0.95rem;
    }

    .json-actions .tool-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.95rem;
    }

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

    .info-card {
        padding: 1rem;
    }
}

@media (max-width: 1024px) {
    .content-header {
        display: none;
    }

    .mobile-header {
        display: flex;
    }

    .sidebar {
        top: var(--header-height);
        left: -250px;
        width: 250px;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .tool-page {
        padding: 0.4rem;
        margin-top: var(--header-height);
    }

    .tool-hero {
        padding: 1rem 0.4rem;
    }

    .tool-hero h1 {
        font-size: 1.6rem;
        gap: 0.4rem;
    }

    .tool-hero p {
        font-size: 0.9rem;
    }

    .converter-card {
        padding: 0.6rem;
        gap: 0.4rem;
    }

    .card-icon {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }

    .converter-header h2 {
        font-size: 1.1rem;
    }

    .input-group {
        margin-bottom: 0.6rem;
    }

    .input-group label {
        font-size: 0.8rem;
    }

    .input-group textarea {
        padding: 0.4rem;
        font-size: 0.85rem;
        min-height: 80px;
    }

    .options-grid {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .option-group label {
        font-size: 0.8rem;
    }

    .select-wrapper select {
        padding: 0.4rem;
        font-size: 0.85rem;
    }

    .select-wrapper i {
        font-size: 0.8rem;
        right: 0.5rem;
    }

    .tool-actions-bottom {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
    }

    .tool-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
        width: 100%;
        justify-content: center;
    }

    .result-section {
        padding: 0.6rem;
    }

    .result-header h3 {
        font-size: 0.9rem;
    }

    .json-preview pre {
        padding: 0.6rem;
        font-size: 0.8rem;
        max-height: 250px;
    }

    .json-actions .tool-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .info-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .info-card {
        padding: 0.6rem;
    }

    .info-icon {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }

    .info-card h3 {
        font-size: 0.9rem;
    }

    .error-notification {
        top: 0.4rem;
        right: 0.4rem;
        padding: 0.6rem;
    }
}

@media (max-width: 480px) {
    .tool-page {
        padding: 0.3rem;
    }

    .tool-hero {
        padding: 0.75rem 0.3rem;
    }

    .tool-hero h1 {
        font-size: 1.4rem;
    }

    .tool-hero p {
        font-size: 0.85rem;
    }

    .converter-card {
        padding: 0.5rem;
    }

    .card-icon {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .converter-header h2 {
        font-size: 1rem;
    }

    .input-group textarea {
        min-height: 60px;
    }

    .tool-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .json-actions .tool-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .result-section {
        padding: 0.5rem;
    }

    .info-card {
        padding: 0.5rem;
    }

    .info-icon {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    .tool-page {
        padding: 0.2rem;
    }

    .tool-hero {
        padding: 0.5rem 0.2rem;
    }

    .tool-hero h1 {
        font-size: 1.3rem;
    }

    .tool-hero p {
        font-size: 0.8rem;
    }

    .converter-card {
        padding: 0.4rem;
    }

    .tool-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }

    .json-actions .tool-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }

    .result-section,
    .info-card {
        padding: 0.4rem;
    }
}

@media (max-width: 320px) {
    .tool-page {
        padding: 0.15rem;
    }

    .tool-hero {
        padding: 0.4rem 0.15rem;
    }

    .tool-hero h1 {
        font-size: 1.2rem;
    }

    .tool-hero p {
        font-size: 0.75rem;
    }

    .mobile-header {
        padding: 0.3rem;
        height: 50px;
    }

    .mobile-menu-toggle {
        font-size: 1rem;
        padding: 0.3rem;
    }

    .mobile-logo {
        font-size: 1rem;
    }

    .mobile-logo i {
        font-size: 1rem;
    }

    .mobile-user img {
        width: 28px;
        height: 28px;
    }
}