/* =========================================================
   ENCBYT MOBILE OVERRIDES v5.1 (PREMIUM APP STYLE)
   Path: css/mobile.css
   Purpose: Native app feel - small fonts, tight spacing
   Load Order: Before mobile-nav.css
   ========================================================= */

/* =========================================================
   1. TABLET (max-width: 1024px)
   ========================================================= */
@media (max-width: 1024px) {
    html body.dashboard-body .dashboard-grid {
        grid-template-columns: repeat(6, 1fr) !important;
    }

    html body.dashboard-body .stats-section,
    html body.dashboard-body .daily-quota-card,
    html body.dashboard-body .wide-card,
    html body.dashboard-body .audit-section {
        grid-column: span 6 !important;
    }

    html body.dashboard-body .shared-metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        padding: 0 12px !important;
    }

    html body.dashboard-body .settings-grid {
        grid-template-columns: 1fr !important;
    }
}

/* =========================================================
   2. MOBILE (max-width: 768px) - APP FEEL
   ========================================================= */
@media (max-width: 768px) {

    /* =========================================================
       GLOBAL TYPOGRAPHY (APP-LIKE)
       ========================================================= */
    html body.dashboard-body,
    html body.auth-mode {
        font-size: 13px !important;
        line-height: 1.4 !important;
        -webkit-text-size-adjust: 100% !important;
        -moz-text-size-adjust: 100% !important;
        text-size-adjust: 100% !important;
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
        text-rendering: optimizeLegibility !important;
    }

    /* Headings */
    html body.dashboard-body h1,
    html body.auth-mode h1 { font-size: 18px !important; line-height: 1.25 !important; letter-spacing: -0.3px !important; }

    html body.dashboard-body h2,
    html body.auth-mode h2 { font-size: 16px !important; line-height: 1.25 !important; letter-spacing: -0.2px !important; }

    html body.dashboard-body h3,
    html body.auth-mode h3 { font-size: 14px !important; line-height: 1.3 !important; }

    html body.dashboard-body h4,
    html body.auth-mode h4 { font-size: 13px !important; line-height: 1.3 !important; }

    html body.dashboard-body h5,
    html body.auth-mode h5 { font-size: 12px !important; line-height: 1.3 !important; }

    /* Paragraphs */
    html body.dashboard-body p,
    html body.auth-mode p {
        font-size: 13px !important;
        line-height: 1.4 !important;
    }

    /* Labels */
    html body.dashboard-body label,
    html body.auth-mode label {
        font-size: 12.5px !important;
        line-height: 1.3 !important;
    }

    /* Small text */
    html body.dashboard-body small,
    html body.auth-mode small,
    html body.dashboard-body .text-muted,
    html body.dashboard-body .text-muted-small {
        font-size: 11.5px !important;
        line-height: 1.3 !important;
    }

    /* Buttons */
    html body.dashboard-body button,
    html body.dashboard-body .btn,
    html body.dashboard-body .btn-primary,
    html body.dashboard-body .btn-secondary,
    html body.auth-mode button {
        font-size: 13px !important;
        line-height: 1.2 !important;
    }

    /* Inputs - 14px (iOS zoom prevent) */
    html body.dashboard-body input,
    html body.dashboard-body select,
    html body.dashboard-body textarea,
    html body.auth-mode input,
    html body.auth-mode select,
    html body.auth-mode textarea {
        font-size: 14px !important;
        line-height: 1.3 !important;
    }

    /* Tables */
    html body.dashboard-body table,
    html body.dashboard-body .premium-table {
        font-size: 12px !important;
    }

    html body.dashboard-body table th,
    html body.dashboard-body .premium-table th {
        font-size: 11px !important;
        line-height: 1.3 !important;
    }

    html body.dashboard-body table td,
    html body.dashboard-body .premium-table td {
        font-size: 12px !important;
        line-height: 1.35 !important;
    }

    /* Lists */
    html body.dashboard-body ul,
    html body.dashboard-body ol {
        font-size: 13px !important;
        line-height: 1.4 !important;
    }

    /* Badges, pills, tags */
    html body.dashboard-body .badge,
    html body.dashboard-body .micro-badge,
    html body.dashboard-body .plan-badge,
    html body.dashboard-body .format-tag,
    html body.dashboard-body .status-indicator {
        font-size: 10.5px !important;
        line-height: 1.2 !important;
    }

    /* Code blocks */
    html body.dashboard-body code,
    html body.dashboard-body pre,
    html body.dashboard-body .session-badge-code {
        font-size: 11.5px !important;
    }

    /* =========================================================
       SPA CONTENT LAYOUT
       ========================================================= */
    html body.dashboard-body #spa-content,
    html body.dashboard-body main#mainContentArea,
    html body.dashboard-body .main-content {
        padding: 0 !important;
        margin: 0 !important;
    }

    html body.dashboard-body #spa-content .spa-stage {
        padding: 0 !important;
    }

    /* =========================================================
       DASHBOARD GRID
       ========================================================= */
    html body.dashboard-body .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        padding: 10px !important;
    }

    html body.dashboard-body .grid-card {
        padding: 14px !important;
        border-radius: 10px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    html body.dashboard-body .card-header h3,
    html body.dashboard-body .card-header-actions h3 {
        font-size: 13px !important;
        font-weight: 700 !important;
    }

    /* Circular stats */
    html body.dashboard-body .circular-stats-container {
        flex-wrap: wrap !important;
        gap: 10px !important;
        justify-content: space-around !important;
    }

    html body.dashboard-body .circle-wrapper {
        width: 56px !important;
        height: 56px !important;
    }

    html body.dashboard-body .circle-stat-box h4 {
        font-size: 11px !important;
    }

    html body.dashboard-body .circle-stat-box p {
        font-size: 10px !important;
    }

    /* Quick upload */
    html body.dashboard-body .quick-upload-zone {
        padding: 16px 10px !important;
    }

    html body.dashboard-body .quick-upload-icon {
        font-size: 24px !important;
    }

    html body.dashboard-body .quick-upload-primary {
        font-size: 12px !important;
    }

    html body.dashboard-body .format-tag {
        font-size: 8.5px !important;
        padding: 2px 4px !important;
    }

    /* Tables scroll */
    html body.dashboard-body .table-responsive,
    html body.dashboard-body .premium-table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 -14px !important;
        padding: 0 14px !important;
    }

    html body.dashboard-body .premium-table {
        font-size: 11.5px !important;
        min-width: 560px !important;
    }

    html body.dashboard-body .premium-table th {
        font-size: 10.5px !important;
        padding: 8px 10px !important;
    }

    html body.dashboard-body .premium-table td {
        font-size: 11.5px !important;
        padding: 10px !important;
    }

    /* Audit list */
    html body.dashboard-body .audit-item {
        padding: 10px !important;
    }

    html body.dashboard-body .audit-info p {
        font-size: 11.5px !important;
    }

    /* =========================================================
       FILES PAGE - ANDROID FILE MANAGER STYLE
       ========================================================= */
    html body.dashboard-body .files-top-toolbar {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 4px !important;
        margin: 0 !important;
        padding: 6px 10px !important;
        width: 100% !important;
        min-height: 0 !important;
        border-bottom: 1px solid #f1f5f9 !important;
        box-sizing: border-box !important;
    }

    html body.dashboard-body .files-top-toolbar .toolbar-left-group,
    html body.dashboard-body .toolbar-center-group {
        display: none !important;
    }

    html body.dashboard-body .toolbar-right-group {
        display: flex !important;
        flex-direction: row !important;
        gap: 4px !important;
        width: auto !important;
        flex: 0 0 auto !important;
        align-items: center !important;
        justify-content: flex-end !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    html body.dashboard-body .toolbar-right-group .tool-select,
    html body.dashboard-body .toolbar-right-group .btn-upload-action,
    html body.dashboard-body .toolbar-right-group .btn-tool-icon:not(.cv-mobile-search-toggle):not(.cv-mobile-menu-toggle) {
        display: none !important;
    }

    html body.dashboard-body .toolbar-search-group {
        order: 10 !important;
        flex: 1 1 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        display: none !important;
    }

    html body.dashboard-body .toolbar-search-group.cv-mobile-visible {
        display: block !important;
        padding: 4px 10px 6px 10px !important;
        border-bottom: 1px solid #f1f5f9 !important;
    }

    /* File grid - 4 column flat */
    html body.dashboard-body #fileListContainer.view-mode-grid,
    html body.dashboard-body .view-mode-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 12px 6px !important;
        padding: 10px 10px 20px 10px !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    html body.dashboard-body .view-mode-grid .native-file-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        text-align: center !important;
        width: 100% !important;
        height: auto !important;
        padding: 2px !important;
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
        cursor: pointer !important;
        gap: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        transition: opacity 0.12s ease !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    html body.dashboard-body .view-mode-grid .native-file-item:active {
        opacity: 0.55 !important;
    }

    html body.dashboard-body .view-mode-grid .grid-card-icon,
    html body.dashboard-body .view-mode-grid .native-icon-wrapper {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 auto 3px auto !important;
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        flex-shrink: 0 !important;
        box-shadow: none !important;
    }

    html body.dashboard-body .view-mode-grid .grid-card-icon .cv-file-svg-icon,
    html body.dashboard-body .view-mode-grid .native-icon-wrapper .cv-file-svg-icon,
    html body.dashboard-body .view-mode-grid .grid-card-icon img,
    html body.dashboard-body .view-mode-grid .native-icon-wrapper img {
        width: 40px !important;
        height: 40px !important;
        display: block !important;
    }

    html body.dashboard-body .view-mode-grid .grid-card-details {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        overflow: hidden !important;
        text-align: center !important;
        background: transparent !important;
    }

    html body.dashboard-body .view-mode-grid .grid-card-title {
        font-size: 11px !important;
        font-weight: 500 !important;
        color: #1f2937 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        line-height: 1.2 !important;
        max-width: 100% !important;
        width: 100% !important;
        letter-spacing: -0.15px !important;
        background: transparent !important;
    }

    html body.dashboard-body .view-mode-grid .grid-card-meta {
        font-size: 9.5px !important;
        font-weight: 400 !important;
        color: #9ca3af !important;
        line-height: 1.1 !important;
        margin-top: 0 !important;
        background: transparent !important;
        letter-spacing: -0.05px !important;
    }

    body.dark-mode .view-mode-grid .grid-card-title,
    [data-theme="dark"] .view-mode-grid .grid-card-title {
        color: #f9fafb !important;
    }

    body.dark-mode .view-mode-grid .grid-card-meta,
    [data-theme="dark"] .view-mode-grid .grid-card-meta {
        color: #6b7280 !important;
    }

    /* List view */
    html body.dashboard-body .view-mode-list {
        padding: 6px 10px 20px 10px !important;
    }

    html body.dashboard-body .view-mode-list .native-file-item {
        height: 50px !important;
        padding: 6px 10px !important;
        border-radius: 8px !important;
    }

    html body.dashboard-body .view-mode-list .list-row-icon {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
    }

    html body.dashboard-body .view-mode-list .list-row-icon .cv-file-svg-icon {
        width: 24px !important;
        height: 24px !important;
    }

    html body.dashboard-body .view-mode-list .list-row-name {
        font-size: 12.5px !important;
    }

    html body.dashboard-body .view-mode-list .list-row-right {
        gap: 8px !important;
        font-size: 10.5px !important;
    }

    /* Classic view */
    html body.dashboard-body .view-mode-classic {
        padding: 8px 10px 20px 10px !important;
    }

    html body.dashboard-body .view-mode-classic .native-file-item {
        width: calc(25% - 6px) !important;
        padding: 4px 2px !important;
        background: transparent !important;
        border: none !important;
    }

    html body.dashboard-body .view-mode-classic .native-icon-wrapper {
        width: 42px !important;
        height: 42px !important;
        margin-bottom: 3px !important;
        background: transparent !important;
        border: none !important;
    }

    html body.dashboard-body .view-mode-classic .native-icon-wrapper .cv-file-svg-icon {
        width: 40px !important;
        height: 40px !important;
    }

    html body.dashboard-body .view-mode-classic .native-file-name {
        font-size: 11px !important;
    }

    html body.dashboard-body .view-mode-classic .native-file-size {
        font-size: 9.5px !important;
    }

    /* =========================================================
       SHARED PAGE
       ========================================================= */
    html body.dashboard-body .shared-top-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        padding: 10px 12px !important;
    }

    html body.dashboard-body .shared-top-toolbar .toolbar-left h2 {
        font-size: 15px !important;
    }

    html body.dashboard-body .shared-top-toolbar .toolbar-center,
    html body.dashboard-body .shared-search-box {
        width: 100% !important;
        max-width: 100% !important;
    }

    html body.dashboard-body .shared-top-toolbar .toolbar-right {
        width: 100% !important;
        justify-content: space-between !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    html body.dashboard-body .shared-tabs-filter {
        width: 100% !important;
        overflow-x: auto !important;
    }

    html body.dashboard-body .tab-pill {
        font-size: 11.5px !important;
        padding: 5px 10px !important;
        white-space: nowrap !important;
    }

    html body.dashboard-body .shared-metrics-grid {
        grid-template-columns: 1fr !important;
        padding: 0 12px !important;
        gap: 8px !important;
    }

    html body.dashboard-body .shared-metric-card {
        padding: 10px 12px !important;
    }

    html body.dashboard-body .metric-value {
        font-size: 17px !important;
    }

    html body.dashboard-body .shared-data-panel {
        margin: 0 12px !important;
        border-radius: 10px !important;
        overflow-x: auto !important;
    }

    html body.dashboard-body .share-modal-dialog {
        width: 95% !important;
        max-width: 95% !important;
        border-radius: 12px !important;
    }

    html body.dashboard-body .share-modal-dialog .modal-header {
        padding: 10px 14px !important;
    }

    html body.dashboard-body .share-modal-dialog .modal-body {
        padding: 14px !important;
    }

    /* =========================================================
       TRASH PAGE
       ========================================================= */
    html body.dashboard-body .trash-top-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 10px 12px !important;
    }

    html body.dashboard-body .trash-header-right {
        width: 100% !important;
        justify-content: flex-end !important;
    }

    html body.dashboard-body .trash-item {
        flex-wrap: wrap !important;
        padding: 10px 12px !important;
        gap: 8px !important;
    }

    html body.dashboard-body .trash-date {
        order: 3 !important;
        width: 100% !important;
        text-align: left !important;
        min-width: 0 !important;
    }

    html body.dashboard-body .trash-actions {
        order: 2 !important;
        margin-left: auto !important;
    }

    /* =========================================================
       SETTINGS PAGE
       ========================================================= */
    html body.dashboard-body .settings-top-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 10px 12px !important;
    }

    html body.dashboard-body .settings-header-left h2 {
        font-size: 16px !important;
    }

    html body.dashboard-body .settings-header-left p {
        font-size: 11.5px !important;
    }

    html body.dashboard-body .settings-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        padding: 0 10px 20px 10px !important;
    }

    html body.dashboard-body .card-settings {
        padding: 14px !important;
    }

    html body.dashboard-body .card-settings h3 {
        font-size: 13px !important;
    }

    html body.dashboard-body .metadata-item {
        font-size: 11.5px !important;
        padding: 9px 11px !important;
    }

    html body.dashboard-body .sec-row {
        font-size: 11.5px !important;
        padding: 11px !important;
    }

    html body.dashboard-body .profile-avatar {
        width: 42px !important;
        height: 42px !important;
        font-size: 16px !important;
    }

    /* =========================================================
       QUOTA CARD
       ========================================================= */
    html body.dashboard-body .quota-item {
        gap: 8px !important;
    }

    html body.dashboard-body .quota-icon {
        width: 28px !important;
        height: 28px !important;
        font-size: 11px !important;
    }

    html body.dashboard-body .quota-label {
        font-size: 10px !important;
    }

    html body.dashboard-body .quota-text {
        font-size: 9.5px !important;
    }

    /* =========================================================
       UPLOAD PANEL
       ========================================================= */
    html body.dashboard-body .upload-panel-container {
        bottom: 72px !important;
        right: 10px !important;
        left: 10px !important;
    }

    html body.dashboard-body .upload-panel-card,
    html body.dashboard-body .media-player-card {
        min-width: auto !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Media player */
    html body.dashboard-body .media-player-container {
        bottom: 72px !important;
        right: 10px !important;
        left: 10px !important;
    }

    /* =========================================================
       DIALOG / MODAL — SIDE-BY-SIDE BUTTONS
       ========================================================= */
    html body.dashboard-body .cv-dialog-box,
    html body.auth-mode .cv-dialog-box {
        max-width: calc(100% - 24px) !important;
        margin: 12px !important;
    }

    html body.dashboard-body .cv-dialog-actions,
    html body.auth-mode .cv-dialog-actions {
        flex-direction: row !important;
        justify-content: flex-end !important;
        gap: 10px !important;
        padding: 14px 16px !important;
    }

    html body.dashboard-body .cv-dialog-actions .cv-btn,
    html body.dashboard-body .cv-btn,
    html body.auth-mode .cv-dialog-actions .cv-btn,
    html body.auth-mode .cv-btn {
        width: auto !important;
        min-width: 88px !important;
        flex: 0 0 auto !important;
        padding: 0 18px !important;
        height: 40px !important;
        font-size: 13px !important;
    }

    html body.dashboard-body .recovery-modal-card {
        padding: 18px 14px !important;
        max-width: calc(100% - 20px) !important;
    }

    /* =========================================================
       LOGIN PAGE — TYPOGRAPHY
       ========================================================= */
    html body.auth-mode .qr-sync-pane,
    html body.auth-mode aside.qr-sync-pane {
        display: none !important;
    }

    html body.auth-mode .main-auth-card {
        grid-template-columns: 1fr !important;
        max-width: 100% !important;
    }

    html body.auth-mode .auth-content-pane {
        padding: 22px 16px !important;
    }

    html body.auth-mode .brand-name {
        font-size: 17px !important;
        letter-spacing: -0.3px !important;
    }

    html body.auth-mode .brand-subtitle {
        font-size: 10.5px !important;
    }

    html body.auth-mode .tab-btn {
        font-size: 12.5px !important;
        padding: 8px 0 !important;
    }

    html body.auth-mode .form-row label,
    html body.auth-mode .form-grp label {
        font-size: 12px !important;
        font-weight: 600 !important;
    }

    html body.auth-mode .input-icon-box input {
        font-size: 16px !important;
        height: 44px !important;
    }

    html body.auth-mode .input-icon-box input::placeholder {
        font-size: 13px !important;
    }

    html body.auth-mode .forgot-link {
        font-size: 11.5px !important;
    }

    html body.auth-mode .autolock-tag {
        font-size: 10.5px !important;
        padding: 2px 7px !important;
    }

    html body.auth-mode .btn-submit-action {
        font-size: 14px !important;
        height: 46px !important;
    }

    html body.auth-mode .btn-recovery-action {
        font-size: 13px !important;
        height: 42px !important;
    }

    html body.auth-mode .sec-assurance {
        font-size: 10.5px !important;
    }

    html body.auth-mode .sec-assurance svg {
        width: 12px !important;
        height: 12px !important;
    }

    html body.auth-mode .micro-badge {
        font-size: 9px !important;
        padding: 2px 6px !important;
    }

    html body.auth-mode .plan-title {
        font-size: 12px !important;
    }

    html body.auth-mode .plan-sub {
        font-size: 10px !important;
    }

    html body.auth-mode .pwd-match-hint {
        font-size: 11px !important;
    }

    html body.auth-mode .auth-feedback-banner {
        font-size: 12px !important;
        padding: 8px 12px !important;
    }

    html body.auth-mode .auth-toast {
        font-size: 12.5px !important;
        padding: 10px 14px !important;
    }
}

/* =========================================================
   3. SMALL MOBILE (max-width: 480px)
   ========================================================= */
@media (max-width: 480px) {
    html body.dashboard-body,
    html body.auth-mode {
        font-size: 12.5px !important;
    }

    html body.dashboard-body #spa-content {
        padding: 0 !important;
    }

    html body.dashboard-body .grid-card {
        padding: 12px !important;
    }

    html body.dashboard-body .card-header h3,
    html body.dashboard-body .card-header-actions h3 {
        font-size: 12.5px !important;
    }

    html body.dashboard-body .quick-upload-zone {
        padding: 14px 8px !important;
    }

    html body.dashboard-body .view-all-link {
        font-size: 10.5px !important;
    }

    /* Grid stays 4-column */
    html body.dashboard-body #fileListContainer.view-mode-grid,
    html body.dashboard-body .view-mode-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px 5px !important;
        padding: 8px 8px 18px 8px !important;
    }

    html body.dashboard-body .view-mode-grid .grid-card-icon,
    html body.dashboard-body .view-mode-grid .native-icon-wrapper {
        width: 38px !important;
        height: 38px !important;
    }

    html body.dashboard-body .view-mode-grid .grid-card-icon .cv-file-svg-icon,
    html body.dashboard-body .view-mode-grid .native-icon-wrapper .cv-file-svg-icon {
        width: 36px !important;
        height: 36px !important;
    }

    html body.dashboard-body .view-mode-grid .grid-card-title {
        font-size: 10.5px !important;
    }

    html body.dashboard-body .view-mode-grid .grid-card-meta {
        font-size: 9px !important;
    }

    /* Login page */
    html body.auth-mode .brand-name {
        font-size: 16px !important;
    }

    html body.auth-mode .tab-btn {
        font-size: 12px !important;
    }

    html body.auth-mode .form-row label {
        font-size: 11.5px !important;
    }

    html body.auth-mode .btn-submit-action {
        font-size: 13.5px !important;
    }
}