/* =============================================================
   ATHENACORE — GLOBAL RESPONSIVE STYLESHEET
   Handles breakpoints for all major page components.
   Breakpoints: 1024px (tablet), 768px (mobile), 480px (xs)
   ============================================================= */

/* ===========================================================
   1. GLOBAL SHELL & APP LAYOUT
   =========================================================== */

@media (max-width: 1024px) {
    .app-content {
        padding: 1.25rem 1rem;
    }
}

@media (max-width: 900px) {
    .app-content {
        padding: 1rem 0.75rem;
    }

    .app-container {
        padding-top: 72px; /* slimmer nav offset on mobile */
    }

    /* Generic grid helpers used across pages */
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr 1fr !important;
    }

    .grid-2 {
        grid-template-columns: 1fr !important;
    }

    .dashboard-hero .hero-row {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .dashboard-hero .hero-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .app-content {
        padding: 0.75rem 0.5rem;
    }

    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr !important;
    }
}

/* ===========================================================
   2. SETTINGS PAGE
   =========================================================== */

@media (max-width: 1024px) {
    .settings-layout {
        grid-template-columns: 220px 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .settings-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .settings-sidebar {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        padding-right: 0;
        scrollbar-width: none;
    }

    .settings-sidebar::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .settings-header h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .settings-container {
        padding: 0;
    }

    .tab-content {
        padding: 1rem;
    }
}

/* ===========================================================
   3. MESSAGES PAGE
   =========================================================== */

@media (max-width: 900px) {
    .messages-layout {
        grid-template-columns: 260px 1fr;
    }
}

@media (max-width: 768px) {
    .messages-layout {
        grid-template-columns: 1fr;
        height: auto;
        min-height: calc(100vh - 80px);
    }

    .messages-sidebar {
        height: auto;
        max-height: 280px;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        overflow-y: auto;
    }

    .messages-main {
        height: calc(100vh - 440px);
        min-height: 320px;
    }

    .chat-header {
        padding: 0.75rem 1rem;
    }

    .chat-messages {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .messages-sidebar {
        max-height: 220px;
    }

    .messages-main {
        min-height: 280px;
    }

    .chat-input-container {
        padding: 0.75rem;
    }
}

/* ===========================================================
   4. AI CHAT PAGE
   =========================================================== */

@media (max-width: 900px) {
    .chat-layout {
        grid-template-columns: 240px 1fr;
    }
}

@media (max-width: 768px) {
    .chat-container {
        height: auto;
    }

    .chat-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .chat-sidebar {
        height: auto;
        max-height: 240px;
        overflow-y: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        padding-bottom: 0.5rem;
    }

    .chat-main {
        height: calc(100vh - 380px);
        min-height: 320px;
    }

    .chat-messages {
        padding: 1rem;
    }

    .chat-input-area {
        padding: 0.75rem 1rem;
    }

    .chat-header {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .chat-sidebar {
        max-height: 180px;
    }

    .chat-main {
        min-height: 280px;
    }

    .input-wrapper {
        gap: 0.5rem;
    }
}

/* ===========================================================
   5. PERFORMANCE DASHBOARD
   =========================================================== */

@media (max-width: 768px) {
    .perf-dashboard-wrapper {
        padding: 0.75rem;
    }

    .perf-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .perf-row {
        flex-direction: column;
    }

    .perf-col-3,
    .perf-col-4,
    .perf-col-6,
    .perf-col-8,
    .perf-col-12 {
        width: 100% !important;
        padding: 0 !important;
        margin-bottom: 1rem;
    }

    .perf-metric-card {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .perf-page-header-title {
        font-size: 1.25rem;
    }

    .perf-metric-value {
        font-size: 1.75rem;
    }
}

/* ===========================================================
   6. PROJECTS — BUGS PANEL & CARDS
   =========================================================== */

@media (max-width: 1024px) {
    .bugs-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .bugs-grid {
        grid-template-columns: 1fr;
    }

    .bdp {
        width: 100vw;
        right: 0;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
    }

    .bdp__meta {
        grid-template-columns: 1fr 1fr;
    }

    .bdp__status-grid {
        grid-template-columns: 1fr 1fr;
    }

    .bugs-stats-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 12px 16px;
    }

    .bugs-stats-bar .stat-item {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 80px;
    }

    .bugs-stats-bar .stat-divider {
        display: none;
    }
}

@media (max-width: 480px) {
    .bdp__meta {
        grid-template-columns: 1fr;
    }

    .bdp__header {
        padding: 1rem;
    }

    .bdp__body {
        padding: 1rem;
    }
}

/* ===========================================================
   7. PROJECTS — KANBAN
   =========================================================== */

@media (max-width: 1200px) {
    .kanban {
        grid-template-columns: repeat(3, minmax(240px, 1fr));
    }
}

@media (max-width: 900px) {
    .kanban {
        grid-template-columns: repeat(2, minmax(240px, 1fr));
    }
}

@media (max-width: 640px) {
    .kanban {
        grid-template-columns: 1fr;
    }
}

/* ===========================================================
   8. PROJECTS — GATES / SPRINTS / DETAILS
   =========================================================== */

@media (max-width: 768px) {
    .gates-grid,
    .sprints-grid {
        grid-template-columns: 1fr;
    }

    .project-detail-layout {
        flex-direction: column;
    }

    .project-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }
}

/* ===========================================================
   9. RECOGNITION — BADGES WALL & MANAGE
   =========================================================== */

@media (max-width: 768px) {
    .badges-grid,
    .awards-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

@media (max-width: 480px) {
    .badges-grid,
    .awards-grid {
        grid-template-columns: 1fr 1fr;
    }

    .badge-card {
        padding: 1rem;
    }
}

/* ===========================================================
   10. RESOURCES — CAPACITY
   =========================================================== */

@media (max-width: 1024px) {
    .capacity-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .capacity-grid {
        grid-template-columns: 1fr;
    }

    .capacity-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ===========================================================
   11. NOTIFICATIONS PAGE
   =========================================================== */

@media (max-width: 768px) {
    .notifications-list {
        gap: 0.75rem;
    }

    .notification-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 1rem;
    }

    .notification-actions {
        align-self: flex-end;
    }
}

/* ===========================================================
   12. GITHUB / TRIGGER WORKFLOW PAGE
   =========================================================== */

@media (max-width: 768px) {
    .workflow-grid,
    .github-grid {
        grid-template-columns: 1fr;
    }

    .repo-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* ===========================================================
   13. SHARED GLASS CARDS & UTILITY GRIDS
   =========================================================== */

@media (max-width: 768px) {
    .glass-card {
        padding: 1.25rem;
        border-radius: 16px;
    }

    /* Shared utility grid overrides */
    [class*="grid-cols-3"],
    [class*="grid-cols-4"] {
        grid-template-columns: 1fr 1fr !important;
    }
}

@media (max-width: 480px) {
    .glass-card {
        padding: 1rem;
        border-radius: 12px;
    }

    [class*="grid-cols-2"],
    [class*="grid-cols-3"],
    [class*="grid-cols-4"] {
        grid-template-columns: 1fr !important;
    }
}

/* ===========================================================
   14. TABLES — OVERFLOW SCROLL ON MOBILE
   =========================================================== */

@media (max-width: 768px) {
    .table-responsive,
    .data-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Apply to all bare tables inside content sections if not wrapped */
    .app-content table {
        min-width: 500px;
    }

    .app-content .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ===========================================================
   15. MODALS — FULL SCREEN ON SMALL SCREENS
   =========================================================== */

@media (max-width: 600px) {
    .modal,
    dialog.modal,
    .modal-box {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 92vh !important;
        border-radius: 20px !important;
        padding: 1.25rem !important;
    }

    .modal-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-actions .btn,
    .modal-actions button {
        width: 100%;
    }
}

/* ===========================================================
   16. FORMS — STACK ON MOBILE
   =========================================================== */

@media (max-width: 640px) {
    .form-row,
    .form-grid,
    .input-row {
        grid-template-columns: 1fr !important;
        flex-direction: column;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .form-actions .btn,
    .form-actions button {
        width: 100%;
    }
}

/* ===========================================================
   17. BUTTONS — TOUCH TARGETS ON MOBILE
   =========================================================== */

@media (max-width: 768px) {
    .btn,
    .action-btn,
    .btn-primary,
    .btn-ghost,
    .btn-danger {
        min-height: 44px; /* WCAG touch target */
    }
}

/* ===========================================================
   18. PAGE HERO / HEADER SECTIONS
   =========================================================== */

@media (max-width: 768px) {
    .page-header,
    .dashboard-hero {
        padding: 1.25rem 1rem;
    }

    .page-title {
        font-size: 1.5rem !important;
    }

    .page-subtitle {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .page-title {
        font-size: 1.25rem !important;
    }

    .hero-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .hero-actions .btn,
    .hero-actions a {
        flex: 1 1 auto;
        text-align: center;
    }
}
