/* ══════════════════════════════════════════════════════════════════════════
   mobile.css — MD Colab Profile · Complete Mobile Overrides
   Breakpoint: 640px and below
   Design philosophy: edge-to-edge, zero outer gaps, compact fonts,
   tight spacing, smooth & native-feeling
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {

/* ── GLOBAL RESETS ──────────────────────────────────────────────────────── */
body {
    font-size: 14px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

/* Prevent iOS zoom on inputs */
input, textarea, select {
    font-size: 16px !important;
}

/* ── TOP NAVIGATION — flush to edges ───────────────────────────────────── */
.top-nav {
    padding: 0 10px;
    height: 52px;
    gap: 6px;
}
.nav-brand {
    font-size: 0;      /* collapse brand name, show logo only */
    gap: 0;
}
.nav-brand-text {
    display: none;
}
.nav-brand .logo {
    width: 30px !important;
    height: 30px;
}
.nav-right {
    gap: 6px;
}
.nav-right .btn-secondary.small {
    padding: 6px 10px;
    font-size: 0.76rem;
    gap: 4px;
    border-radius: 6px;
}
.theme-toggle-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-right: 4px;
}
#nav-profile-img {
    width: 32px;
    height: 32px;
}

/* Account Dropdown — full width on mobile */
.account-dropdown {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 0 0 14px 14px;
    max-height: calc(100dvh - 52px);
    overflow-y: auto;
}
.current-account-header {
    padding: 10px 14px;
    font-size: 0.68rem;
}
.account-item {
    padding: 10px 14px;
    gap: 10px;
}
.acc-avatar { width: 30px; height: 30px; }
.acc-name { font-size: 0.82rem; }
.acc-email { font-size: 0.68rem; }
.AT3 { margin: 6px 8px 0; padding: 6px 8px; }
.action-item { padding: 11px 14px; font-size: 0.82rem; gap: 8px; }

/* ── MAIN LAYOUT — no padding, edge-to-edge ────────────────────────────── */
.main-layout {
    padding: 0;
    margin: 0;
}

/* ── TAB NAVIGATION — compact, edge-flush ──────────────────────────────── */
.tab-nav {
    margin-bottom: 0;
    padding: 0 6px;
    gap: 0;
    border-bottom-width: 1px;
    -webkit-overflow-scrolling: touch;
}
.tab-btn {
    padding: 10px 12px;
    font-size: 0.78rem;
    gap: 5px;
    border-bottom-width: 2px;
}
.tab-btn i {
    font-size: 0.82rem;
}

/* ── PROFILE TAB — stacked, full width ─────────────────────────────────── */
#tab-profile.active {
    display: flex !important;
    flex-direction: column;
    gap: 0;
}

/* ── PROFILE CARD — edge-to-edge, no border-radius ─────────────────────── */
.profile-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 20px 14px 16px;
}
.profile-picture-wrapper {
    width: 80px;
    height: 80px;
    margin-bottom: 10px;
}
.photo-edit-overlay {
    width: 26px;
    height: 26px;
    font-size: 0.7rem;
}
#profile-name {
    font-size: 1.1rem;
    margin-bottom: 2px;
}
#profile-email {
    font-size: 0.76rem;
    margin-bottom: 6px;
}
.badge-role {
    font-size: 0.65rem;
    padding: 3px 9px;
}
.profile-actions {
    margin: 12px 0 10px;
    gap: 6px;
}
.profile-actions .btn-primary,
.profile-actions .btn-secondary {
    padding: 9px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
    gap: 5px;
}

/* Info Sections inside profile card */
.info-section {
    padding-top: 10px;
    margin-top: 10px;
}
.info-section h4 {
    font-size: 0.65rem;
    letter-spacing: 1px;
    margin-bottom: 6px;
}
.bio-text {
    font-size: 0.82rem;
    line-height: 1.5;
}
.skills-container { gap: 5px; }
.skill-tag {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 5px;
}
.address-display {
    font-size: 0.8rem;
    gap: 6px;
    margin-bottom: 6px;
}
.socials-container { gap: 6px; }
.social-link-icon {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
}
.custom-link-tag {
    font-size: 0.72rem;
    padding: 3px 8px;
}

/* Edit form inside profile card */
#edit-form h4 {
    font-size: 0.82rem !important;
    padding-bottom: 8px !important;
}
.form-group {
    margin-bottom: 10px;
}
.form-group label {
    font-size: 0.72rem;
    margin-bottom: 4px;
    letter-spacing: 0.4px;
}
.form-group input,
.form-group textarea,
.form-group select {
    padding: 9px 10px;
    font-size: 16px !important;   /* iOS zoom prevention */
    border-radius: 8px;
}
.custom-link-group {
    gap: 6px;
    margin-bottom: 6px;
}
.custom-link-group input {
    padding: 9px 10px;
}
.remove-custom-link-btn {
    width: 30px;
    height: 30px;
}
.btn-add-link {
    padding: 8px;
    font-size: 0.78rem;
}
.form-actions {
    gap: 6px;
    margin-top: 10px;
    flex-direction: column;
}
.form-actions .btn-primary,
.form-actions .btn-secondary {
    width: 100%;
    justify-content: center;
    padding: 10px;
    font-size: 0.82rem;
}

/* ── PROFILE RIGHT PANEL ───────────────────────────────────────────────── */
.profile-right-panel {
    gap: 0;
}

/* Panel cards — edge-to-edge */
.panel-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 14px 14px;
    border-bottom: none;
    border-top: 1px solid var(--border);
}
.panel-card-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
}
.panel-card-header h3 {
    font-size: 0.82rem;
    gap: 6px;
}
.panel-card-header h3 i {
    font-size: 0.85rem;
}

/* Activity Stats */
.activity-stats {
    gap: 6px;
}
.activity-stat {
    padding: 10px 6px;
    border-radius: 8px;
}
.activity-stat .stat-num {
    font-size: 1.3rem;
    margin-bottom: 2px;
}
.activity-stat .stat-lbl {
    font-size: 0.68rem;
}

/* Membership Info */
.membership-info-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.membership-info-item {
    padding: 8px 10px;
    border-radius: 6px;
}
.membership-info-item .mi-label {
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.membership-info-item .mi-value {
    font-size: 0.8rem;
}

/* Quick Links */
.quick-links-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.quick-link-item {
    padding: 10px 10px;
    font-size: 0.78rem;
    gap: 7px;
    border-radius: 8px;
}
.quick-link-item i { font-size: 0.88rem; }

/* ── OVERVIEW TAB ──────────────────────────────────────────────────────── */
.stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px 0;
}
.stat-card {
    padding: 12px 14px;
    border-radius: 10px;
    gap: 12px;
    border-radius: 0;
    border-left: none;
    border-right: none;
}
.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 1.1rem;
}
.stat-info h3 {
    font-size: 1.35rem;
}
.stat-info p {
    font-size: 0.76rem;
}

.collab-details-section {
    grid-template-columns: 1fr;
    gap: 0;
}
.detail-column {
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 14px;
}
.section-header {
    padding-bottom: 8px;
    margin-bottom: 10px;
}
.section-header h2 {
    font-size: 0.95rem;
    gap: 7px;
}
.item-list-container { gap: 6px; }
.list-item-card {
    padding: 9px 10px;
    font-size: 0.82rem;
}

/* ── PORTFOLIO BUILDER TAB ─────────────────────────────────────────────── */
#tab-settings .content-section {
    padding: 0 !important;
}
#tab-settings .section-header {
    padding: 14px 14px 10px;
    margin-bottom: 0;
    border-bottom: none;
}
#tab-settings .section-header h2 {
    font-size: 1.15rem !important;
    gap: 8px;
}
#tab-settings .section-header p {
    font-size: 0.8rem !important;
    margin-top: 4px;
}

#portfolio-settings-form {
    gap: 0 !important;
}

/* Settings premium cards — edge-to-edge */
.settings-premium-card {
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    padding: 14px 14px 16px !important;
    gap: 14px !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
.settings-premium-card::before {
    display: none;
}
.settings-premium-card:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Premium card headers */
.premium-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-bottom: 10px;
}
.premium-card-header h4 {
    font-size: 0.82rem !important;
    letter-spacing: 0.6px !important;
    gap: 6px !important;
}
.premium-card-header > div {
    width: 100%;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

/* Inputs inside premium cards */
.settings-premium-card input,
.settings-premium-card select,
.settings-premium-card textarea {
    padding: 10px 12px !important;
    font-size: 16px !important;   /* iOS zoom prevention */
    border-radius: 8px !important;
}
.settings-premium-card .form-group label {
    font-size: 0.76rem !important;
    margin-bottom: 4px !important;
}

/* Input with prefix (portfolio URL) — stacked */
.input-with-prefix {
    flex-direction: column !important;
    align-items: stretch !important;
    border-radius: 8px !important;
    overflow: hidden !important;
}
.input-with-prefix > span {
    border-right: none !important;
    border-bottom: 1px solid rgba(255,255,255,0.06) !important;
    padding: 8px 12px !important;
    font-size: 0.78rem !important;
    width: 100% !important;
}
.light-mode .input-with-prefix > span {
    border-bottom-color: rgba(0,0,0,0.08) !important;
}
.input-with-prefix input {
    width: 100% !important;
    padding: 10px 12px !important;
}

.full-width-select {
    font-size: 16px !important;
    padding: 9px 10px;
    border-radius: 8px;
}

/* Premium toggles */
.premium-switch-container {
    padding: 10px 12px;
    border-radius: 10px;
}
.premium-switch {
    width: 44px;
    height: 24px;
}
.premium-slider:before {
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
}
.premium-switch input:checked + .premium-slider:before {
    transform: translateX(20px);
}

/* Portfolio item previews */
.portfolio-item-preview {
    padding: 10px 12px !important;
    border-radius: 8px !important;
}
.portfolio-item-preview:hover {
    transform: none !important;
}

/* Dynamic fields */
.dynamic-fields-box,
.dynamic-fields-box-premium {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 12px;
    margin-top: 8px;
}

/* Color customization section */
#color-customization-section {
    padding: 12px !important;
    border-radius: 8px !important;
    gap: 10px !important;
    flex-direction: column !important;
}

/* Perk message */
.perk-message {
    padding: 10px 12px !important;
    font-size: 0.78rem !important;
    gap: 8px !important;
    border-radius: 8px !important;
}

/* Cloudinary upload */
.cld-drop-zone {
    padding: 14px !important;
    border-radius: 10px !important;
}
.cld-drop-zone i { font-size: 1.3rem !important; }
.cld-drop-zone p { font-size: 0.76rem !important; }


/* ── ACCOUNT TAB ───────────────────────────────────────────────────────── */
#tab-account .content-section {
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 14px;
}
#tab-account .section-header h2 {
    font-size: 0.95rem;
}

/* Device items */
.device-item {
    padding: 10px;
    gap: 8px;
    flex-direction: column;
    align-items: flex-start;
    border-radius: 8px;
    margin-bottom: 6px;
}
.device-info {
    gap: 10px;
    width: 100%;
}
.device-icon-wrapper {
    width: 34px !important;
    height: 34px !important;
    font-size: 1rem !important;
}
.device-details p {
    font-size: 0.8rem !important;
    white-space: normal !important;
}
.device-details small {
    font-size: 0.68rem;
}
.device-tag {
    font-size: 0.6rem;
    padding: 1px 5px;
}
.btn-remove-device {
    padding: 5px 10px;
    font-size: 0.72rem;
    width: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* ── BUTTONS — global compact sizing ───────────────────────────────────── */
.btn-primary {
    padding: 9px 14px;
    font-size: 0.82rem;
    border-radius: 8px;
    gap: 5px;
}
.btn-primary:hover { transform: none; }
.btn-secondary {
    padding: 9px 14px;
    font-size: 0.82rem;
    border-radius: 8px;
    gap: 5px;
}
.btn-danger {
    padding: 9px 14px;
    font-size: 0.82rem;
    border-radius: 8px;
}
.small {
    padding: 7px 10px;
    font-size: 0.76rem;
}
.btn-manage {
    font-size: 0.68rem;
    padding: 3px 8px;
}

/* ── MODALS — bottom sheet style ───────────────────────────────────────── */
.modal-overlay {
    align-items: flex-end;
    padding: 0;
}
.modal {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 16px 16px 0 0;
    padding: 16px 14px 24px;
    -webkit-overflow-scrolling: touch;
}
.modal-header h2 {
    font-size: 1rem;
    margin-bottom: 6px;
}
.close-modal-btn {
    top: 12px;
    right: 12px;
    font-size: 1.1rem;
}
.pin-box {
    padding: 12px;
    letter-spacing: 2px;
    font-size: 0.9rem;
}

/* Swipe indicator pill */
.modal::before,
.aem-modal::before {
    width: 32px;
    height: 3px;
    margin: 0 auto 10px;
}

/* Add Element Modal */
.aem-modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh !important;
    border-radius: 16px 16px 0 0 !important;
    padding: 0 !important;
}
.aem-modal > div:first-child {
    padding: 12px 14px 0;
}
#aem-grid {
    padding: 0 14px 14px;
}
.aem-element-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
}
.aem-element-card {
    padding: 10px 12px !important;
}
#aem-categories {
    gap: 4px !important;
    padding-bottom: 3px;
}
.aem-cat-btn {
    font-size: 0.75rem !important;
    padding: 5px 10px !important;
}
#aem-search {
    font-size: 16px !important;
    padding: 9px 10px !important;
}

/* Element Form Modal */
#aem-form-modal {
    padding: 0 !important;
    align-items: flex-end;
}
#aem-form-modal > div {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh !important;
    border-radius: 16px 16px 0 0 !important;
    padding: 14px 14px 24px !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* JSON Editor Modal */
#json-editor-modal .modal {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 14px 14px 20px;
}
.modal-item-content small {
    max-width: 100% !important;
}
#modal-item-list {
    max-height: 140px !important;
}
.modal-form-area {
    padding: 10px;
}
.modal-form-area h4 {
    font-size: 0.85rem !important;
    margin-bottom: 10px !important;
}

/* Quick Login & PIN modals */
#quick-login-modal .modal,
#pin-modal .modal {
    max-height: 92dvh;
    overflow-y: auto;
}
#otp-entry {
    font-size: 1rem !important;
    letter-spacing: 4px !important;
}

/* ── TOAST — left/right flush ──────────────────────────────────────────── */
#toast-container {
    bottom: 12px;
    right: 8px;
    left: 8px;
}
.toast {
    max-width: 100%;
    padding: 10px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* ── MARKDOWN EDITOR — single column ───────────────────────────────────── */
.markdown-editor {
    grid-template-columns: 1fr;
    gap: 8px;
}
.markdown-editor textarea {
    height: 150px;
    font-size: 0.82rem;
}
.markdown-preview-area {
    height: 150px;
    font-size: 0.82rem;
    padding: 10px;
}

/* ── VALIDATION MESSAGES ───────────────────────────────────────────────── */
.validation-msg {
    font-size: 0.74rem;
}

/* ── SCROLLBAR — thinner on mobile ─────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; height: 3px; }

/* ── VERIFIED TICK — scale ─────────────────────────────────────────────── */
.verified-tick img {
    width: 24px;
    margin-bottom: 18px;
}

/* ── MISC HELPER OVERRIDES ─────────────────────────────────────────────── */
.text-muted.small { font-size: 0.76rem; }

/* Disable hover effects on touch */
@media (hover: none) {
    .activity-stat:hover,
    .stat-card:hover,
    .app-connect-card:hover,
    .quick-link-item:hover,
    .skill-tag:hover,
    .social-link-icon:hover,
    .portfolio-item-preview:hover,
    .settings-premium-card:hover {
        transform: none !important;
    }
}

}  /* END @media (max-width: 640px) */


/* ══════════════════════════════════════════════════════════════════════════
   EXTRA-SMALL DEVICES — 380px and below (iPhone SE, etc.)
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {

    .top-nav { padding: 0 6px; }

    .tab-btn {
        padding: 8px 8px;
        font-size: 0.72rem;
    }
    .tab-btn i { font-size: 0.78rem; }

    .profile-card { padding: 16px 10px 12px; }
    .profile-picture-wrapper { width: 64px; height: 64px; margin-bottom: 8px; }
    #profile-name { font-size: 0.95rem; }
    #profile-email { font-size: 0.7rem; }

    .activity-stat .stat-num { font-size: 1.1rem; }
    .activity-stat .stat-lbl { font-size: 0.62rem; }

    .membership-info-grid { grid-template-columns: 1fr; gap: 5px; }

    .quick-links-grid { grid-template-columns: 1fr; gap: 5px; }

    .settings-premium-card { padding: 10px 10px 14px !important; }
    .premium-card-header h4 { font-size: 0.76rem !important; }

    .aem-element-grid { grid-template-columns: 1fr !important; }

    .modal { padding: 12px 10px 20px; }
    .modal-header h2 { font-size: 0.9rem; }
}


/* ══════════════════════════════════════════════════════════════════════════
   MEDIUM BREAKPOINT — 420px element grid bump
   ══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 420px) and (max-width: 640px) {
    .aem-element-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}


/* ══════════════════════════════════════════════════════════════════════════
   DESKTOP RESTORE — ensure modals and overlays show correctly above 640px
   ══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 641px) {
    .modal-overlay { align-items: center; padding: 1rem; }
    .modal {
        border-radius: var(--radius);
        padding: 2rem;
        max-height: 90vh;
        max-width: 420px;
    }
    .modal::before,
    .aem-modal::before { display: none; }
    .aem-modal {
        border-radius: var(--radius) !important;
        max-height: 90vh !important;
        width: 95vw !important;
    }
    .aem-modal > div:first-child { padding: 1.5rem 2rem 0; }
    #aem-grid { padding: 0 2rem 1.5rem; }
    #aem-form-modal { padding: 1rem !important; align-items: center; }
    #aem-form-modal > div {
        border-radius: var(--radius) !important;
        padding: 2rem !important;
        max-height: 90vh !important;
        max-width: 560px !important;
    }
    #json-editor-modal .modal {
        border-radius: var(--radius);
        padding: 2rem;
        max-width: 600px;
    }
    #modal-item-list { max-height: 200px !important; }
}
