/*==============================
    RESPONSIVE DESIGN
==============================*/

/* Large Tablets and Small Desktops */
@media (max-width: 1200px) {

    .app-layout {
        grid-template-columns: 1fr;
    }

    .app-layout.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    header {

        width: 100%;

        height: auto;

        position: sticky;

        top: 0;

        flex-direction: row;

        justify-content: space-between;

        align-items: center;

        padding: 12px 16px;

        border-right: none;

        border-bottom: 1px solid rgba(255,255,255,0.1);

        z-index: 1000;

    }

    header.sidebar-collapsed {

        width: 100%;

        padding: 12px 16px;

    }

    .main-content {
        padding-left: 0;
    }

    .logo {

        margin: 0;

        font-size: 18px;

    }

    .logo i {

        font-size: 20px;

    }

    nav {

        display: none;

        position: fixed;

        top: 60px;

        left: 0;

        right: 0;

        background: rgba(7,12,28,0.98);

        backdrop-filter: blur(20px);

        padding: 16px;

        border-radius: 0 0 16px 16px;

        flex-direction: column;

        flex-wrap: nowrap;

        gap: 4px;

        max-height: calc(100vh - 60px);

        overflow-y: auto;

        z-index: 999;

        order: 1;

        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

    }

    nav.active {

        display: flex;

    }

    nav a {

        flex: none;

        width: 100%;

        justify-content: flex-start;

        padding: 14px 16px;

        border-radius: 8px;

        transition: background 0.2s ease;

    }

    nav a:hover {

        background: rgba(0, 229, 255, 0.1);

    }

    nav a.active {

        background: rgba(0, 229, 255, 0.2);

    }

    .nav-label {

        display: block;

        font-size: 14px;

    }

    .nav-icon {

        font-size: 18px;

        margin-right: 12px;

    }

    .sidebar-toggle {

        display: flex;

        margin: 0;

        order: 3;

        padding: 10px;

        font-size: 18px;

    }

    .theme-btn {

        display: flex;

        order: 2;

        margin-left: auto;

        margin-right: 12px;

        padding: 10px;

        font-size: 18px;

    }

    .hero {

        flex-direction: column;

        padding: 80px 6% 60px;

        text-align: center;

    }

    .hero-left {

        order: 2;

    }

    .hero-right {

        order: 1;

    }

    .coil-container {

        margin-bottom: 40px;

    }

    .stats {

        grid-template-columns: repeat(2, 1fr);

        padding: 40px 6%;

    }

    .card-container {

        grid-template-columns: repeat(2, 1fr);

    }

    .menu {

        display: flex;

        margin-left: auto;

        margin-right: 20px;

    }

    /* Experiment pages responsive */
    .lab-container {

        flex-direction: column;

    }

    .control-panel,
    .simulation-area,
    .reading-panel {

        width: 100%;

    }

    .dashboard-panel {

        flex-direction: column;

    }

    .graph-panel,
    .obs-panel {

        width: 100%;

    }

}

/* Tablets */
@media (max-width: 768px) {

    header {

        padding: 10px 14px;

    }

    .logo {

        font-size: 16px;

    }

    .logo i {

        font-size: 18px;

    }

    .hero h1 {

        font-size: clamp(28px, 8vw, 42px);

    }

    .hero p {

        font-size: 15px;

        line-height: 1.6;

    }

    .stats {

        grid-template-columns: 1fr;

        padding: 30px 5%;

        gap: 16px;

    }

    .card-container {

        grid-template-columns: 1fr;

        gap: 16px;

    }

    .hero-buttons {

        flex-direction: column;

        width: 100%;

        gap: 12px;

    }

    .primary-btn,
    .secondary-btn {

        width: 100%;

        padding: 14px 20px;

        font-size: 15px;

    }

    .coil-container {

        width: 280px;

        height: 280px;

    }

    .outer-ring {

        width: 240px;

        height: 240px;

    }

    .middle-ring {

        width: 180px;

        height: 180px;

    }

    .inner-ring {

        width: 120px;

        height: 120px;

    }

    .core {

        width: 60px;

        height: 60px;

        font-size: 24px;

    }

    /* Experiment pages */
    .control-panel,
    .reading-panel {

        padding: 16px;

    }

    .simulation-area {

        min-height: 350px;

    }

    .reading-card {

        padding: 16px;

    }

    .observation-table {

        font-size: 13px;

    }

    /* Dashboard responsive */
    .experiment-grid {

        grid-template-columns: repeat(2, 1fr);

        gap: 12px;

    }

    .action-grid {

        grid-template-columns: repeat(2, 1fr);

        gap: 12px;

    }

    /* Page title */
    .page-title {

        padding: 80px 5% 30px;

    }

    .page-title h1 {

        font-size: clamp(24px, 6vw, 32px);

    }

}

/* Mobile Phones */
@media (max-width: 480px) {

    body {
        padding-left: 0;
    }

    header {
        width: 100%;
        height: auto;
        position: sticky;
        top: 0;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 10px 12px;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .logo {
        font-size: 15px;
    }

    .logo i {
        font-size: 16px;
    }

    nav {
        top: 52px;
        padding: 12px;
    }

    nav a {
        padding: 12px 14px;
    }

    .nav-label {
        font-size: 13px;
    }

    .nav-icon {
        font-size: 16px;
    }

    .sidebar-toggle {
        padding: 8px;
        font-size: 16px;
    }

    .theme-btn {
        padding: 8px;
        font-size: 16px;
        margin-right: 8px;
    }

    .hero {

        padding: 70px 4% 30px;

    }

    .hero h1 {

        font-size: clamp(24px, 10vw, 32px);

        line-height: 1.2;

    }

    .hero p {

        font-size: 14px;

        line-height: 1.6;

    }

    .tag {

        font-size: 11px;

        padding: 6px 12px;

    }

    .stat-card {

        padding: 20px;

    }

    .stat-card h2 {

        font-size: 22px;

    }

    .stat-card p {

        font-size: 13px;

    }

    .exp-card {

        padding: 20px;

    }

    .exp-card i {

        font-size: 28px;

    }

    .exp-card h3 {

        font-size: 15px;

    }

    .exp-card p {

        font-size: 13px;

    }

    .coil-container {

        width: 200px;

        height: 200px;

    }

    .outer-ring {

        width: 180px;

        height: 180px;

    }

    .middle-ring {

        width: 130px;

        height: 130px;

    }

    .inner-ring {

        width: 90px;

        height: 90px;

    }

    .core {

        width: 45px;

        height: 45px;

        font-size: 18px;

    }

    /* Experiment pages mobile */
    .control-panel label {

        font-size: 13px;

    }

    .control-panel input[type="range"] {

        height: 6px;

    }

    .reading-card {

        padding: 12px;

    }

    .reading-card h3 {

        font-size: 12px;

    }

    .reading-card span {

        font-size: 15px;

    }

    .observation-table {

        font-size: 11px;

    }

    .observation-table th,
    .observation-table td {

        padding: 6px 3px;

    }

    /* Responsive canvas elements */
    canvas {
        max-width: 100%;
        height: auto !important;
    }

    /* Responsive SVG elements */
    svg {
        max-width: 100%;
        height: auto;
        overflow: visible;
    }

    .circuit-diagram {
        max-width: 100%;
        height: auto;
        overflow: visible;
        padding: 10px;
    }

    #circuit {
        overflow: visible;
        min-height: 250px;
    }

    #circuit svg {
        width: 100%;
        height: 100%;
        overflow: visible;
    }

    /* Graph panel responsive */
    .graph-panel {
        overflow: hidden;
        padding: 16px;
    }

    .graph-panel canvas {
        width: 100% !important;
        height: auto !important;
    }

    .graph-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .graph-header h2 {
        font-size: 16px;
    }

    .graph-toggle {
        padding: 6px 12px;
        font-size: 12px;
    }

    /* Make observation table scrollable instead of hiding columns */
    .obs-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
    }

    .observation-table {
        min-width: 500px;
        white-space: nowrap;
    }

    /* Dashboard mobile */
    .experiment-grid {

        grid-template-columns: 1fr;

        gap: 12px;

    }

    .action-grid {

        grid-template-columns: 1fr;

        gap: 12px;

    }

    .dashboard-header {

        flex-direction: column;

        gap: 12px;

    }

    .dashboard-header nav {

        display: none;

    }

    /* Page title mobile */
    .page-title {

        padding: 70px 4% 24px;

    }

    .page-title h1 {

        font-size: clamp(20px, 8vw, 28px);

    }

    .page-title p {

        font-size: 13px;

    }

    /* Lab container mobile */
    .lab-container {

        padding: 12px 4% 20px;

        gap: 12px;

    }

    .dashboard-panel {

        padding: 0 4% 24px;

        gap: 12px;

    }

    .simulation-box {

        min-height: 280px;

    }

    /* Buttons mobile */
    .primary-btn,
    .secondary-btn {

        padding: 12px 16px;

        font-size: 14px;

    }

    /* Loader mobile */
    .loader-shell {
        width: 170px;
        height: 170px;
    }

    .loader-text {
        font-size: 1rem;
        letter-spacing: 0.08em;
    }

    .loader-progress {
        width: 180px;
    }

}

/* Medium Mobile - 375px to 430px */
@media (max-width: 430px) and (min-width: 376px) {

    body {
        padding-left: 0;
    }

    header {
        padding: 10px 14px;
    }

    .hero {
        padding: 65px 4% 28px;
    }

    .lab-container {
        padding: 12px 4% 20px;
    }

    .dashboard-panel {
        padding: 0 4% 24px;
    }

    .simulation-box {
        min-height: 300px;
    }

    .observation-table {
        min-width: 550px;
    }
}

/* Small Mobile - 375px */
@media (max-width: 375px) {

    body {
        padding-left: 0;
    }

    header {
        padding: 8px 12px;
    }

    .logo {
        font-size: 14px;
    }

    .logo i {
        font-size: 15px;
    }

    .lab-container {
        padding: 10px 3% 18px;
    }

    .dashboard-panel {
        padding: 0 3% 22px;
    }

    .simulation-box {
        min-height: 260px;
    }

    .observation-table {
        min-width: 500px;
    }

    .graph-panel,
    .obs-panel {
        padding: 12px;
    }
}

/* Extra Small Devices - 320px */
@media (max-width: 360px) {

    body {
        padding-left: 0;
    }

    header {
        width: 100%;
        height: auto;
        position: sticky;
        top: 0;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 8px 10px;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .logo {
        font-size: 13px;
    }

    .logo i {
        font-size: 14px;
    }

    nav {
        top: 48px;
    }

    nav.active {
        padding: 10px;
    }

    nav a {
        font-size: 12px;
        padding: 10px 12px;
    }

    .nav-icon {
        font-size: 14px;
    }

    .nav-label {
        font-size: 11px;
    }

    .sidebar-toggle {
        padding: 6px;
        font-size: 14px;
    }

    .theme-btn {
        padding: 6px;
        font-size: 14px;
        margin-right: 6px;
    }

    .lab-container {
        padding: 8px 3% 16px;
    }

    .dashboard-panel {
        padding: 0 3% 20px;
    }

    .control-panel,
    .simulation-area,
    .reading-panel,
    .graph-panel,
    .obs-panel {
        padding: 10px;
    }

    .simulation-box {
        min-height: 220px;
    }

    .control-panel label {
        font-size: 11px;
    }

    .reading-card {
        padding: 8px;
    }

    .reading-card h3 {
        font-size: 11px;
    }

    .reading-card span {
        font-size: 13px;
    }

    .observation-table {
        font-size: 10px;
    }

    .observation-table th,
    .observation-table td {
        padding: 5px 2px;
    }

    .observation-table {
        min-width: 450px;
    }

    .primary-btn,
    .secondary-btn {
        padding: 10px 14px;
        font-size: 12px;
    }

    .hero h1 {

        font-size: clamp(18px, 10vw, 24px);

    }

    .hero p {

        font-size: 12px;

    }

    .stat-card h2 {

        font-size: 18px;

    }

    .stat-card p {

        font-size: 12px;

    }

    .exp-card i {

        font-size: 24px;

    }

    .exp-card h3 {

        font-size: 14px;

    }

    .exp-card p {

        font-size: 12px;

    }

    .page-title h1 {

        font-size: clamp(18px, 8vw, 24px);

    }

    .page-title p {

        font-size: 12px;

    }

    /* Responsive canvas elements */
    canvas {
        max-width: 100%;
        height: auto !important;
    }

    /* Responsive SVG elements */
    svg {
        max-width: 100%;
        height: auto;
    }

    .circuit-diagram {
        max-width: 100%;
        height: auto;
    }

    /* Graph panel responsive */
    .graph-panel {
        overflow: hidden;
    }

    .graph-panel canvas {
        width: 100% !important;
        height: auto !important;
    }

    /* Make observation table scrollable */
    .obs-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .observation-table {
        min-width: 600px;
        white-space: nowrap;
    }

    .primary-btn,
    .secondary-btn {
        padding: 10px;
        font-size: 12px;
    }

    .hero h1 {

        font-size: 24px;

    }

    .hero p {

        font-size: 13px;

    }

    .stat-card h2 {

        font-size: 20px;

    }

    .exp-card i {

        font-size: 28px;

    }

    .exp-card h3 {

        font-size: 15px;

    }

    .exp-card p {

        font-size: 13px;

    }

    .primary-btn,
    .secondary-btn {

        padding: 14px 24px;

        font-size: 14px;

    }

    /* Navigation adjustments */
    header {

        padding: 12px 15px;

    }

    .logo {

        font-size: 18px;

    }

    .logo i {

        font-size: 16px;

    }

    nav.active {

        padding: 15px;

    }

    nav a {

        font-size: 12px;

        padding: 8px 12px;

    }

    .nav-icon {

        font-size: 14px;

    }

    .nav-label {

        font-size: 11px;

    }

}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {

    .hero {

        flex-direction: row;

        padding: 40px 6%;

    }

    .hero-left {

        order: 1;

    }

    .hero-right {

        order: 2;

    }

    .coil-container {

        width: 200px;

        height: 200px;

        margin-bottom: 0;

    }

}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {

    .atom-svg,
    .coil-container {

        image-rendering: -webkit-optimize-contrast;

    }

}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .exp-card:hover,
    .stat-card:hover,
    .reading-card:hover {
        transform: none;
    }

    /* Increase tap targets */
    .exp-card,
    .stat-card {
        min-height: 80px;
    }

    /* Improve scroll performance */
    .obs-panel,
    .graph-panel {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Prevent zoom on form inputs */
    input[type="text"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px;
    }
}

/* Print styles */
@media print {

    body {

        background: white;

        color: black;

    }

    header,
    .background,
    .loader-overlay,

    .sidebar-toggle,
    .theme-btn {

        display: none;

    }

    .hero,

    .stats,

    .experiments {

        padding: 20px;

    }

    .exp-card {

        break-inside: avoid;

        border: 1px solid #ccc;

    }

}