/* ============================================
   CALCULATOR MOBILE RESPONSIVENESS
   ============================================ */

/* General Calculator Grid Layout */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    width: 100%;
}

/* Dashboard Layout */
.dashboard-main-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

/* Base Responsive Cards */
.card {
    width: 100%;
    overflow-x: hidden;
    /* Prevent content overflow */
}

/* Zener Calculator Specific Mobile Fixes */
#zener-calculator {
    overflow-x: hidden;
}

#zener-calculator .card {
    padding: 1rem;
}

#zener-calculator .chart-container {
    height: 250px !important;
    max-height: 250px;
}

#zener-calculator .diagram-box {
    min-height: 150px !important;
    padding: 0.5rem !important;
}

/* Tables Mobile Fixes */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-container table {
    min-width: 600px;
}

/* Scrollbar styling for tables */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

/* Mobile Adjustments */
@media (max-width: 768px) {

    /* Stack Grid Wrapper */
    .calc-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Adjust Inputs */
    .input-group {
        flex-direction: column;
        align-items: stretch;
    }

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

    .input-group input,
    .input-group select {
        width: 100%;
        font-size: 16px;
        /* Prevent zoom */
        padding: 10px;
    }

    /* Adjust Buttons */
    .btn-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn {
        width: 100%;
        padding: 12px;
        justify-content: center;
    }

    /* Tabs scrollable horizontally */
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        gap: 0.5rem;
    }

    .tabs::-webkit-scrollbar {
        height: 4px;
    }

    .tab {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    /* Results Grid */
    .result-grid {
        grid-template-columns: 1fr;
        /* Stack results */
        gap: 0.75rem;
    }

    /* Charts */
    .chart-container {
        height: 250px !important;
        /* Smaller height on mobile */
        width: 100% !important;
        position: relative;
    }

    /* Specific Tool Adjustments */

    /* 555 Timer Inputs */
    .input-group div[style*="display: flex"] {
        flex-direction: column;
    }

    /* Converters and General 2-Column Grids */
    .grid-2 {
        grid-template-columns: 1fr !important;
    }

    .grid-2>* {
        grid-column: auto !important;
    }

    /* Resistor Color Code Visual */
    .resistor-visual {
        transform: scale(0.8);
        /* Shrink slightly if needed */
        margin: 1rem 0;
    }

    /* Filter Calculator Tabs */
    #filter-calculator .tabs {
        justify-content: flex-start;
    }

    /* History List */
    .history-list-container {
        grid-template-columns: 1fr !important;
    }

    /* Input Rows (OpAmp) */
    .input-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }

    .input-row .input-group {
        min-width: 0 !important;
        width: 100% !important;
    }
}

/* Small Mobile (320px - 480px) */
@media (max-width: 480px) {
    .content-header h2 {
        font-size: 1.5rem;
    }

    .content-header p {
        font-size: 0.9rem;
    }

    /* Stats cards in Dashboard */
    .stats-container {
        grid-template-columns: 1fr !important;
    }

    /* Dashboard Main Grid */
    .dashboard-main-grid {
        grid-template-columns: 1fr !important;
    }

    /* Hide some visual flair if needed */
    .welcome-icon {
        font-size: 2rem;
    }
}