/**
 * Tech Earth CRM - Dedicated Responsive Stylesheet v2.0
 * Breakpoints: Large Desktop (1280px+), Laptop (1025-1279px), Tablet (769-1024px), Mobile (<=768px)
 */

/* ==========================================================================
   1. Medium Desktop / Laptop Screens (1025px - 1279px)
   ========================================================================== */
@media (max-width: 1279px) and (min-width: 1025px) {
    .dash-kpi-grid,
    .stats-grid-4 {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
    }

    .dash-split-grid,
    .dashboard-grid {
        grid-template-columns: 1.25fr 1fr;
        gap: 18px;
    }

    .layout-aside-380 {
        grid-template-columns: minmax(0, 1fr) 330px;
    }

    .page-content {
        padding: 22px;
    }

    .topbar-search-bar {
        max-width: 240px;
    }
}

/* ==========================================================================
   2. Tablet Screens (769px - 1024px)
   ========================================================================== */
@media (max-width: 1024px) and (min-width: 769px) {
    .app-sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .app-sidebar .sidebar-brand-text,
    .app-sidebar .menu-text,
    .app-sidebar .menu-pill-accent,
    .app-sidebar .menu-category,
    .app-sidebar .sidebar-footer {
        display: none;
    }

    .app-sidebar .sidebar-brand {
        justify-content: center;
        padding: 14px 8px;
    }

    .app-sidebar .menu-link {
        justify-content: center;
        padding: 12px;
    }

    .app-sidebar .menu-link .menu-icon {
        font-size: 19px;
    }

    .app-main {
        margin-left: var(--sidebar-collapsed-width);
    }

    .dash-kpi-grid,
    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    .stats-grid-3 {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    .dash-split-grid,
    .dashboard-grid,
    .dashboard-bottom-grid,
    .layout-aside-380,
    .layout-aside-320,
    .full-calendar-layout,
    .client-view-split,
    .profile-grid,
    .att-punch-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .client-details-grid,
    .client-details-grid-secondary {
        grid-template-columns: repeat(2, 1fr);
    }

    .pipeline-stages-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .topbar-search-bar {
        max-width: 220px;
    }

    .topbar-date {
        display: none;
    }

    .page-content {
        padding: 20px;
    }
}

/* ==========================================================================
   3. Mobile Screens (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* Off-canvas Slide Sidebar */
    .app-sidebar {
        transform: translateX(-100%);
        width: 276px;
        box-shadow: 8px 0 32px rgba(1, 20, 50, 0.35);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .sidebar-mobile-close {
        display: inline-flex;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(1, 20, 50, 0.56);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        z-index: 999;
        display: none;
    }

    .sidebar-backdrop.show {
        display: block;
    }

    .app-main {
        margin-left: 0 !important;
        width: 100%;
    }

    /* Topbar Compact */
    .app-topbar {
        padding: 0 14px;
        height: 58px;
    }

    .topbar-search-bar,
    .topbar-date,
    .desktop-user-meta {
        display: none !important;
    }

    .topbar-left {
        gap: 10px;
        flex: 0 0 auto;
    }

    .topbar-right {
        gap: 8px;
    }

    .live-clock-badge {
        font-size: 11px;
        padding: 5px 9px;
    }

    .profile-dropdown-panel {
        right: 0 !important;
        width: 240px !important;
    }

    .notif-dropdown-panel,
    .dropdown-panel {
        right: -52px !important;
        width: min(310px, calc(100vw - 24px)) !important;
    }

    /* Page Content & Header */
    .page-content {
        padding: 16px 14px 28px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 18px;
    }

    .page-title {
        font-size: 18.5px;
    }

    .page-title > i {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .page-header-actions {
        width: 100%;
    }

    .page-header-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    /* KPIs & Stats Grids */
    .dash-kpi-grid,
    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stats-grid-3 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .dash-kpi-card {
        padding: 14px 12px;
        gap: 10px;
        min-height: 82px;
    }

    .dash-kpi-icon {
        width: 40px;
        height: 40px;
        border-radius: 11px;
        font-size: 16px;
    }

    .dash-kpi-number {
        font-size: 21px;
    }

    .dash-kpi-label {
        font-size: 11.5px;
    }

    .stat-card {
        padding: 14px 15px;
    }

    .stat-value {
        font-size: 19px;
    }

    /* Stack All Multi-column Grids */
    .dash-split-grid,
    .dashboard-grid,
    .dashboard-bottom-grid,
    .layout-split-2,
    .layout-aside-380,
    .layout-aside-320,
    .full-calendar-layout,
    .profile-grid,
    .doc-upload-grid,
    .client-view-split,
    .client-details-grid,
    .client-details-grid-secondary,
    .att-punch-grid,
    .wizard-personal-grid,
    .login-summary-banner,
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .login-summary-item {
        border-right: none;
        padding-right: 0;
        padding-bottom: 10px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    }

    .login-summary-item:last-child {
        padding-bottom: 0;
        border-bottom: none;
    }

    .att-timers-grid {
        grid-template-columns: 1fr;
    }

    .teams-grid {
        grid-template-columns: 1fr;
    }

    .profile-hero-card {
        padding: 20px 18px;
    }

    .profile-hero-team-box {
        width: 100%;
        text-align: left;
    }

    /* Pipeline & Filters */
    .pipeline-stages-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .pipeline-stage-box {
        padding: 11px 8px;
        min-height: 74px;
    }

    .pipeline-stage-box .stage-count {
        font-size: 20px;
    }

    .pipeline-filter-bar,
    .filter-bar-form {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .pipeline-filter-group,
    .filter-search-col,
    .filter-col {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .pipeline-filter-actions,
    .filter-actions-col {
        width: 100%;
    }

    .pipeline-filter-actions .btn,
    .filter-actions-col .btn {
        flex: 1;
        justify-content: center;
    }

    /* Cards & Buttons */
    .card {
        border-radius: var(--radius-md);
        margin-bottom: 16px;
    }

    .card-header {
        padding: 14px 16px;
    }

    .card-body {
        padding: 16px;
    }

    .btn {
        min-height: 40px;
    }

    .btn-sm, .btn-xs {
        min-height: 34px;
    }

    /* Full Calendar Mobile Compact */
    .full-calendar-grid {
        gap: 4px;
    }

    .full-cal-empty,
    .full-cal-cell {
        min-height: 62px;
        padding: 4px;
        border-radius: 7px;
    }

    .full-cal-weekday {
        font-size: 10px;
        padding: 6px 2px;
    }

    .cal-pill-tag {
        font-size: 9px;
        padding: 1px 3px;
    }

    /* Modals: Mobile Sheet */
    .modal-overlay {
        padding: 10px;
        align-items: flex-end;
    }

    .modal-dialog {
        max-width: 100% !important;
        border-radius: var(--radius-xl) var(--radius-xl) 12px 12px;
        max-height: 92vh;
    }

    .modal-body {
        padding: 18px;
        max-height: calc(90vh - 125px);
    }

    .modal-footer {
        padding: 12px 18px;
        flex-direction: column-reverse;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* Mobile Card Tables */
    .mobile-table-card-view thead {
        display: none;
    }

    .mobile-table-card-view,
    .mobile-table-card-view tbody,
    .mobile-table-card-view tr,
    .mobile-table-card-view td {
        display: block;
        width: 100%;
    }

    .mobile-table-card-view tbody {
        padding: 10px;
    }

    .mobile-table-card-view tr {
        background: #ffffff;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        margin-bottom: 12px;
        padding: 12px 14px;
        box-shadow: var(--shadow-xs);
    }

    .mobile-table-card-view tr:last-child {
        margin-bottom: 0;
    }

    .mobile-table-card-view td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        padding: 8px 0;
        border-bottom: 1px solid var(--border-light);
        font-size: 13px;
        text-align: right;
    }

    .mobile-table-card-view td:last-child {
        border-bottom: none;
        padding-top: 10px;
        justify-content: flex-end;
    }

    .mobile-table-card-view td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-grey);
        font-size: 11.5px;
        text-align: left;
        flex-shrink: 0;
    }

    .mobile-table-card-view td[data-label=""]::before,
    .mobile-table-card-view td:not([data-label])::before {
        display: none;
    }

    .mobile-table-card-view td[colspan] {
        display: block;
        text-align: center;
        padding: 24px 12px;
        border-bottom: none;
    }

    .mobile-table-card-view td[colspan]::before {
        display: none;
    }

    /* Auth Split Screen Mobile */
    .auth-split-wrapper {
        flex-direction: column;
    }

    .auth-left-hero {
        display: none !important;
    }

    .auth-right-container {
        width: 100% !important;
        min-height: 100vh;
        padding: 24px 16px !important;
    }

    .auth-mobile-brand {
        display: flex;
    }

    .auth-card-modern,
    .auth-card {
        padding: 26px 20px !important;
    }

    .app-footer {
        padding: 14px 16px;
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 420px) {
    .dash-kpi-grid,
    .stats-grid-4 {
        grid-template-columns: 1fr;
    }
}
