/* ===== Responsive Design ===== */

/* Tablet: 768px - 1024px */
@media (max-width: 1024px) {
    .header-inner {
        padding: var(--space-md) var(--space-lg);
    }

    .sidebar {
        width: 240px;
    }

    .main-content {
        padding: var(--space-lg);
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

/* Small Tablet: 640px - 768px */
@media (max-width: 768px) {
    .header-inner {
        padding: var(--space-sm) var(--space-md);
        gap: var(--space-sm);
        flex-wrap: wrap;
    }

    .header-brand {
        gap: var(--space-sm);
    }

    .brand-icon {
        font-size: 1.5rem;
    }

    .brand-title {
        font-size: var(--font-size-lg);
    }

    .brand-subtitle {
        display: none;
    }

    .header-actions {
        flex: 1 1 100%;
        max-width: none;
        order: 3;
    }

    .search-wrapper {
        max-width: none;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 150;
        transform: translateX(-100%);
        width: 280px;
        padding-top: calc(73px + var(--space-md));
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 140;
        background: var(--color-bg-overlay);
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-normal);
    }

    .sidebar-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-toggle {
        display: flex;
    }

    .main-content {
        padding: var(--space-md);
        width: 100%;
    }

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

    .content-title {
        font-size: var(--font-size-xl);
    }

    .tools-grid {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }

    .tool-card {
        padding: var(--space-md);
    }

    .tools-grid.list-view .tool-card {
        flex-direction: column;
        align-items: flex-start;
        padding: var(--space-md);
    }

    .tools-grid.list-view .tool-card-body {
        flex-direction: column;
        align-items: flex-start;
    }

    .tools-grid.list-view .tool-card-name {
        min-width: 0;
    }

    .detail-panel {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .detail-content {
        padding: var(--space-lg) var(--space-md);
    }

    .detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .detail-related {
        grid-template-columns: 1fr;
    }
}

/* Mobile: 320px - 640px */
@media (max-width: 640px) {
    html {
        font-size: 15px;
    }

    .header-inner {
        padding: var(--space-sm);
    }

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

    .brand-title {
        font-size: var(--font-size-base);
    }

    .theme-toggle {
        width: 36px;
        height: 36px;
    }

    .main-content {
        padding: var(--space-sm);
    }

    .content-header {
        margin-bottom: var(--space-md);
        gap: var(--space-sm);
    }

    .content-title {
        font-size: var(--font-size-lg);
    }

    .content-controls {
        width: 100%;
        justify-content: space-between;
    }

    .sort-select {
        flex: 1;
    }

    .tools-grid {
        gap: var(--space-sm);
    }

    .tool-card {
        padding: var(--space-md);
        gap: var(--space-sm);
    }

    .tool-card-icon {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
        border-radius: var(--radius-sm);
    }

    .tool-card-name {
        font-size: var(--font-size-sm);
    }

    .tool-card-desc {
        font-size: var(--font-size-xs);
    }

    .tool-card-tag {
        font-size: 10px;
        padding: 2px 6px;
    }

    .tool-card-badge {
        right: var(--space-md);
        padding: 1px 8px;
        font-size: 9px;
    }

    .sidebar {
        width: 100%;
    }

    .sidebar-toggle {
        bottom: var(--space-md);
        left: var(--space-md);
        width: 40px;
        height: 40px;
    }

    .detail-panel {
        border-radius: 0;
    }

    .detail-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }

    .detail-name {
        font-size: var(--font-size-xl);
    }

    .detail-link {
        width: 100%;
        justify-content: center;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .app-header {
        position: relative;
    }

    .sidebar {
        top: 0;
        padding-top: var(--space-md);
    }

    .detail-panel {
        max-height: 100vh;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .sidebar-toggle,
    .header-actions,
    .detail-overlay {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    .tool-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
