/* ========================================
   ULTRA ADAPTIVE TEXT & BUTTONS MOBILE
   ======================================== */

/* Mobile Ultra-Adaptive Typography */
@media (max-width: 480px) {
    /* Enhanced Text Scaling */
    html {
        font-size: 12px; /* Base ultra-compact */
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    body {
        font-size: 0.85rem; /* 13.6px base */
        line-height: 1.4;
        word-spacing: -0.02em;
        letter-spacing: 0.01em;
    }
    
    /* Ultra-Compact Headings */
    h1 { 
        font-size: 1.25rem; /* 20px */
        line-height: 1.2;
        margin-bottom: 0.5rem;
        font-weight: 700;
    }
    
    h2 { 
        font-size: 1.1rem; /* 17.6px */
        line-height: 1.2;
        margin-bottom: 0.4rem;
        font-weight: 600;
    }
    
    h3 { 
        font-size: 1rem; /* 16px */
        line-height: 1.3;
        margin-bottom: 0.35rem;
        font-weight: 600;
    }
    
    h4 { 
        font-size: 0.9rem; /* 14.4px */
        line-height: 1.3;
        margin-bottom: 0.3rem;
        font-weight: 600;
    }
    
    h5 { 
        font-size: 0.85rem; /* 13.6px */
        line-height: 1.3;
        margin-bottom: 0.25rem;
        font-weight: 500;
    }
    
    h6 { 
        font-size: 0.8rem; /* 12.8px */
        line-height: 1.3;
        margin-bottom: 0.2rem;
        font-weight: 500;
    }
    
    /* Adaptive Paragraphs */
    p {
        font-size: 0.85rem; /* 13.6px */
        line-height: 1.5;
        margin-bottom: 0.75rem;
        text-align: left;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Compact Lists */
    ul, ol {
        font-size: 0.8rem; /* 12.8px */
        margin-bottom: 0.5rem;
        padding-left: 1.2rem;
    }
    
    li {
        margin-bottom: 0.25rem;
        line-height: 1.3;
    }
    
    /* Small Text Elements */
    small {
        font-size: 0.75rem; /* 12px */
        line-height: 1.3;
    }
    
    .text-xs {
        font-size: 0.7rem; /* 11.2px */
        line-height: 1.2;
    }
    
    .text-sm {
        font-size: 0.75rem; /* 12px */
        line-height: 1.3;
    }
    
    /* Navigation Text */
    .navbar-brand h1 {
        font-size: 0.9rem; /* 14.4px */
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .navbar-brand h1 span {
        display: none; /* Hide long text */
    }
    
    .nav-link {
        font-size: 0.8rem; /* 12.8px */
        padding: 0.4rem 0.6rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Sidebar Text */
    .sidebar-nav a {
        font-size: 0.85rem; /* 13.6px */
        padding: 0.6rem 0.8rem;
        line-height: 1.3;
    }
    
    .sidebar-nav a span {
        font-size: 0.8rem; /* 12.8px */
    }
    
    /* Dashboard Headers */
    .dashboard-header h2 {
        font-size: 1.1rem; /* 17.6px */
        line-height: 1.2;
        margin-bottom: 0.3rem;
    }
    
    .welcome-message {
        font-size: 0.8rem; /* 12.8px */
        line-height: 1.3;
        opacity: 0.8;
    }
    
    /* Section Headers */
    .section-header h2 {
        font-size: 1rem; /* 16px */
        line-height: 1.2;
        margin-bottom: 0.5rem;
    }
    
    .section-header p {
        font-size: 0.8rem; /* 12.8px */
        line-height: 1.3;
    }
    
    /* Card Text */
    .card-title {
        font-size: 0.9rem; /* 14.4px */
        line-height: 1.2;
        margin-bottom: 0.3rem;
    }
    
    .card-text {
        font-size: 0.8rem; /* 12.8px */
        line-height: 1.4;
        margin-bottom: 0.5rem;
    }
    
    /* Form Labels */
    .form-group label {
        font-size: 0.8rem; /* 12.8px */
        margin-bottom: 0.3rem;
        font-weight: 600;
    }
    
    /* Button Text */
    .btn {
        font-size: 0.75rem; /* 12px */
        font-weight: 500;
        line-height: 1.2;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .btn-sm {
        font-size: 0.7rem; /* 11.2px */
    }
    
    .btn-lg {
        font-size: 0.8rem; /* 12.8px */
    }
    
    /* Stats Text */
    .stat-value {
        font-size: 1.1rem; /* 17.6px */
        font-weight: 700;
        line-height: 1.1;
    }
    
    .stat-label {
        font-size: 0.7rem; /* 11.2px */
        line-height: 1.2;
        opacity: 0.8;
    }
    
    /* Filter Text */
    .filter-tab {
        font-size: 0.7rem; /* 11.2px */
        font-weight: 500;
        line-height: 1.2;
    }
    
    .filter-select {
        font-size: 0.75rem; /* 12px */
    }
    
    /* Table Text */
    table {
        font-size: 0.7rem; /* 11.2px */
    }
    
    th, td {
        font-size: 0.7rem; /* 11.2px */
        line-height: 1.2;
        padding: 0.3rem 0.2rem;
    }
    
    /* Modal Text */
    .modal-title {
        font-size: 1rem; /* 16px */
        line-height: 1.2;
    }
    
    .modal-body {
        font-size: 0.8rem; /* 12.8px */
        line-height: 1.4;
    }
    
    /* Notification Text */
    .notification {
        font-size: 0.75rem; /* 12px */
        line-height: 1.3;
    }
    
    /* Alert Text */
    .alert {
        font-size: 0.75rem; /* 12px */
        line-height: 1.3;
    }
    
    /* Empty State Text */
    .empty-state h4 {
        font-size: 0.9rem; /* 14.4px */
    }
    
    .empty-state p {
        font-size: 0.8rem; /* 12.8px */
    }
    
    /* Link Text */
    a {
        font-size: 0.85rem; /* 13.6px */
    }
    
    /* Code Text */
    code {
        font-size: 0.75rem; /* 12px */
        padding: 0.2rem 0.3rem;
    }
    
    /* Blockquote */
    blockquote {
        font-size: 0.8rem; /* 12.8px */
        line-height: 1.4;
        padding: 0.5rem;
    }
}

/* Ultra-Compact Buttons */
@media (max-width: 480px) {
    /* Base Button Styles */
    .btn {
        padding: 0.3rem 0.6rem; /* Ultra-compact padding */
        border-radius: 4px;
        min-height: 32px; /* Reduced from 36px */
        width: auto;
        max-width: 100%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.3rem;
        font-weight: 500;
        transition: all 0.2s ease;
        box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }
    
    /* Button Sizes */
    .btn-xs {
        padding: 0.2rem 0.4rem;
        min-height: 24px;
        font-size: 0.65rem; /* 10.4px */
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        min-height: 28px;
        font-size: 0.7rem; /* 11.2px */
    }
    
    .btn-lg {
        padding: 0.4rem 0.8rem;
        min-height: 36px;
        font-size: 0.8rem; /* 12.8px */
    }
    
    .btn-xl {
        padding: 0.5rem 1rem;
        min-height: 40px;
        font-size: 0.85rem; /* 13.6px */
    }
    
    /* Button Widths */
    .btn-block {
        width: 100%;
        display: flex;
    }
    
    .btn-compact {
        padding: 0.2rem 0.4rem;
        min-height: 28px;
    }
    
    /* Button Icons */
    .btn i {
        font-size: 0.9em;
        margin-right: 0.2rem;
    }
    
    .btn i:last-child {
        margin-right: 0;
    }
    
    .btn-icon-only {
        padding: 0.3rem;
        min-height: 32px;
        width: 32px;
    }
    
    .btn-icon-only i {
        margin: 0;
        font-size: 1em;
    }
    
    /* Button Groups */
    .btn-group {
        display: flex;
        gap: 0.25rem;
        flex-wrap: wrap;
    }
    
    .btn-group .btn {
        flex: 1;
        min-width: 0;
    }
    
    .btn-group-vertical {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .btn-group-vertical .btn {
        width: 100%;
    }
    
    /* Navigation Buttons */
    .navbar-actions .btn {
        padding: 0.3rem 0.5rem;
        min-height: 30px;
        font-size: 0.7rem;
    }
    
    .navbar-actions .btn i {
        font-size: 0.8em;
        margin-right: 0.15rem;
    }
    
    /* Sidebar Buttons */
    .sidebar-nav a {
        padding: 0.5rem 0.7rem;
        min-height: 36px;
        font-size: 0.8rem;
        border-radius: 4px;
        margin-bottom: 0.2rem;
    }
    
    /* Dashboard Action Buttons */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-buttons .btn {
        width: 100%;
        min-height: 36px;
        padding: 0.4rem 0.8rem;
    }
    
    /* Form Buttons */
    .form-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .form-actions .btn {
        width: 100%;
        min-height: 40px;
        padding: 0.5rem 1rem;
    }
    
    /* Modal Buttons */
    .modal-footer .btn {
        padding: 0.4rem 0.8rem;
        min-height: 36px;
        font-size: 0.75rem;
    }
    
    /* Card Buttons */
    .card .btn {
        padding: 0.3rem 0.6rem;
        min-height: 28px;
        font-size: 0.7rem;
    }
    
    /* Table Action Buttons */
    .table-actions .btn {
        padding: 0.2rem 0.3rem;
        min-height: 24px;
        font-size: 0.65rem;
    }
    
    /* Filter Buttons */
    .filter-tab {
        padding: 0.3rem 0.6rem;
        min-height: 28px;
        font-size: 0.7rem;
        border-radius: 3px;
    }
    
    /* Social Buttons */
    .social-btn {
        padding: 0.4rem 0.8rem;
        min-height: 36px;
        font-size: 0.8rem;
    }
    
    /* Floating Action Buttons */
    .fab {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        padding: 0;
        font-size: 1.2rem;
    }
    
    .fab-sm {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    /* Toggle Buttons */
    .toggle-btn {
        padding: 0.3rem 0.6rem;
        min-height: 30px;
        font-size: 0.7rem;
    }
    
    /* Icon Buttons */
    .icon-btn {
        padding: 0.3rem;
        min-height: 32px;
        width: 32px;
        border-radius: 4px;
    }
    
    /* Button States */
    .btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    }
    
    .btn:active {
        transform: translateY(0);
        box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }
    
    /* Button Variants */
    .btn-primary {
        background: var(--primary-color);
        color: white;
        border: 1px solid var(--primary-color);
    }
    
    .btn-secondary {
        background: var(--secondary-color);
        color: white;
        border: 1px solid var(--secondary-color);
    }
    
    .btn-outline {
        background: transparent;
        color: var(--primary-color);
        border: 1px solid var(--primary-color);
    }
    
    .btn-outline:hover {
        background: var(--primary-color);
        color: white;
    }
    
    /* Disabled Buttons */
    .btn:disabled,
    .btn.disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none;
        box-shadow: none;
    }
    
    /* Loading Buttons */
    .btn.loading {
        position: relative;
        color: transparent;
    }
    
    .btn.loading::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 12px;
        height: 12px;
        margin: -6px 0 0 -6px;
        border: 2px solid currentColor;
        border-radius: 50%;
        border-top-color: transparent;
        animation: spin 1s linear infinite;
    }
    
    /* Button with Dropdown */
    .btn-dropdown {
        padding-right: 1.5rem;
        position: relative;
    }
    
    .btn-dropdown::after {
        content: "▼";
        position: absolute;
        right: 0.5rem;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.6em;
    }
    
    /* Split Buttons */
    .btn-split {
        display: flex;
        border-radius: 4px;
        overflow: hidden;
    }
    
    .btn-split .btn:first-child {
        border-right: 1px solid rgba(255,255,255,0.2);
        flex: 1;
    }
    
    .btn-split .btn:last-child {
        padding: 0 0.4rem;
        min-width: auto;
    }
}

/* Small Mobile (≤360px) - Even More Compact */
@media (max-width: 360px) {
    /* Even Smaller Text */
    html {
        font-size: 11px;
    }
    
    body {
        font-size: 0.8rem; /* 12.8px */
    }
    
    h1 { font-size: 1.1rem; /* 17.6px */ }
    h2 { font-size: 1rem; /* 16px */ }
    h3 { font-size: 0.9rem; /* 14.4px */ }
    h4 { font-size: 0.85rem; /* 13.6px */ }
    
    p {
        font-size: 0.8rem; /* 12.8px */
        margin-bottom: 0.5rem;
    }
    
    /* Even Smaller Buttons */
    .btn {
        padding: 0.25rem 0.5rem;
        min-height: 28px;
        font-size: 0.65rem; /* 10.4px */
    }
    
    .btn-sm {
        padding: 0.2rem 0.4rem;
        min-height: 24px;
        font-size: 0.6rem; /* 9.6px */
    }
    
    .btn-lg {
        padding: 0.3rem 0.6rem;
        min-height: 32px;
        font-size: 0.7rem; /* 11.2px */
    }
    
    .navbar-actions .btn {
        padding: 0.25rem 0.4rem;
        min-height: 26px;
        font-size: 0.65rem;
    }
    
    .sidebar-nav a {
        padding: 0.4rem 0.6rem;
        min-height: 32px;
        font-size: 0.75rem;
    }
    
    .action-buttons .btn {
        min-height: 32px;
        padding: 0.3rem 0.6rem;
    }
    
    .form-actions .btn {
        min-height: 36px;
        padding: 0.4rem 0.8rem;
    }
}

/* Large Mobile (481px-568px) - Optimized */
@media (min-width: 481px) and (max-width: 568px) {
    /* Slightly Larger Text */
    html {
        font-size: 13px;
    }
    
    body {
        font-size: 0.9rem; /* 14.4px */
    }
    
    h1 { font-size: 1.4rem; /* 22.4px */ }
    h2 { font-size: 1.2rem; /* 19.2px */ }
    h3 { font-size: 1.1rem; /* 17.6px */ }
    
    /* Slightly Larger Buttons */
    .btn {
        padding: 0.35rem 0.7rem;
        min-height: 36px;
        font-size: 0.8rem; /* 12.8px */
    }
    
    .btn-sm {
        padding: 0.3rem 0.6rem;
        min-height: 32px;
        font-size: 0.75rem; /* 12px */
    }
    
    .btn-lg {
        padding: 0.5rem 1rem;
        min-height: 40px;
        font-size: 0.9rem; /* 14.4px */
    }
    
    .navbar-actions .btn {
        padding: 0.35rem 0.7rem;
        min-height: 34px;
        font-size: 0.75rem;
    }
    
    .sidebar-nav a {
        padding: 0.6rem 0.9rem;
        min-height: 40px;
        font-size: 0.85rem;
    }
    
    .action-buttons .btn {
        min-height: 40px;
        padding: 0.5rem 1rem;
    }
    
    .form-actions .btn {
        min-height: 44px;
        padding: 0.6rem 1.2rem;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) and (max-width: 768px) {
    /* Larger Touch Targets */
    .btn {
        min-height: 36px;
        padding: 0.4rem 0.8rem;
    }
    
    .btn-sm {
        min-height: 32px;
        padding: 0.3rem 0.6rem;
    }
    
    .btn-xs {
        min-height: 28px;
        padding: 0.2rem 0.4rem;
    }
    
    /* Enhanced Active States */
    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* No Hover Effects */
    .btn:hover {
        transform: none;
        box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }
}

/* High DPI Mobile */
@media (-webkit-min-device-pixel-ratio: 2) and (max-width: 768px) {
    /* Sharper Borders */
    .btn {
        border-width: 0.5px;
    }
    
    /* Crisper Icons */
    .btn i {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    /* Compact Layout */
    .btn {
        min-height: 30px;
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
    }
    
    .navbar-actions .btn {
        min-height: 28px;
        padding: 0.25rem 0.5rem;
        font-size: 0.65rem;
    }
    
    /* Horizontal Button Groups */
    .btn-group-vertical {
        flex-direction: row;
        gap: 0.25rem;
    }
    
    .btn-group-vertical .btn {
        width: auto;
        min-width: 80px;
    }
}

/* Dark Mode Mobile */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .btn {
        border-width: 0.5px;
    }
    
    .btn-outline {
        color: #4a9eff;
        border-color: #4a9eff;
    }
    
    .btn-outline:hover {
        background: #4a9eff;
        color: #000;
    }
}

/* Reduced Motion Mobile */
@media (prefers-reduced-motion: reduce) and (max-width: 768px) {
    .btn {
        transition: none;
    }
    
    .btn:hover,
    .btn:active {
        transform: none;
    }
    
    .btn.loading::after {
        animation: none;
    }
}

/* ========================================
   ADAPTIVE TEXT WRAPPING
   ======================================== */

@media (max-width: 480px) {
    /* Smart Text Wrapping */
    .text-wrap {
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    
    .text-nowrap {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .text-clamp-2 {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .text-clamp-3 {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    /* Responsive Font Sizes */
    .text-responsive {
        font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    }
    
    .text-responsive-sm {
        font-size: clamp(0.7rem, 2vw, 0.8rem);
    }
    
    .text-responsive-lg {
        font-size: clamp(0.8rem, 3vw, 1rem);
    }
    
    /* Adaptive Line Heights */
    .leading-tight {
        line-height: 1.2;
    }
    
    .leading-normal {
        line-height: 1.4;
    }
    
    .leading-relaxed {
        line-height: 1.6;
    }
    
    /* Text Alignment */
    .text-left-mobile {
        text-align: left !important;
    }
    
    .text-center-mobile {
        text-align: center !important;
    }
    
    .text-right-mobile {
        text-align: right !important;
    }
}
