/**
 * Mobile Responsive & UI Improvements
 * Enhanced for mobile devices and better UX
 */

:root {
    --mobile-padding: 16px;
    --mobile-button-min-height: 44px;
}

/* ============================================
   MOBILE NAVIGATION & LAYOUT
   ============================================ */

@media (max-width: 768px) {
    .app-layout {
        display: flex;
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar.active::after {
        opacity: 1;
        z-index: 998;
    }

    .main-content {
        flex: 1;
        width: 100%;
        padding: 16px;
    }

    /* Mobile Menu Toggle Button */
    .mobile-menu-toggle {
        display: flex !important;
        position: fixed;
        bottom: 24px;
        right: 16px;
        z-index: 900;
        width: 56px;
        height: 56px;
        background: linear-gradient(135deg, var(--primary), var(--accent));
        border: none;
        border-radius: 50%;
        color: white;
        font-size: 20px;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0, 255, 255, 0.3);
        transition: all 0.3s ease;
    }

    .mobile-menu-toggle:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 16px rgba(0, 255, 255, 0.4);
    }

    .mobile-menu-toggle:active {
        transform: scale(0.95);
    }
}

/* Hide mobile toggle on desktop */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
    }
}

/* ============================================
   RESPONSIVE TYPOGRAPHY
   ============================================ */

@media (max-width: 768px) {
    .page-title {
        font-size: 24px !important;
        margin-bottom: 12px;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 18px;
    }

    h4 {
        font-size: 16px;
    }

    body {
        font-size: 14px;
    }
}

/* ============================================
   RESPONSIVE FORMS & INPUTS
   ============================================ */

@media (max-width: 768px) {
    .form-input,
    .form-textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px 14px !important;
        min-height: 44px;
        border-radius: 8px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-label {
        font-size: 14px;
        margin-bottom: 8px;
    }

    /* Stacked form layout on mobile */
    .form-row {
        flex-direction: column;
    }

    .form-row .form-group {
        width: 100%;
    }
}

/* ============================================
   RESPONSIVE BUTTONS
   ============================================ */

@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 8px;
    }

    .btn-icon {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    /* Full width buttons on mobile */
    .btn-block {
        width: 100%;
    }

    /* Stack buttons vertically on mobile */
    .button-group {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .button-group .btn {
        width: 100%;
    }
}

/* ============================================
   RESPONSIVE CARDS & GRID
   ============================================ */

@media (max-width: 768px) {
    .file-grid,
    .folder-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }

    .file-card,
    .folder-card {
        padding: 12px;
    }

    .file-card .file-icon,
    .folder-card .folder-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .share-card-detailed {
        margin-bottom: 16px;
        padding: 0;
    }

    .share-header {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }

    .share-header-actions {
        width: 100%;
        justify-content: stretch;
    }

    .share-header-actions .btn {
        flex: 1;
        font-size: 13px;
        padding: 8px 12px;
    }

    .share-details-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .file-grid,
    .folder-grid {
        grid-template-columns: 1fr !important;
    }

    .share-card-detailed {
        border-radius: 12px;
    }
}

/* ============================================
   RESPONSIVE MODALS & DIALOGS
   ============================================ */

@media (max-width: 768px) {
    .modal {
        width: 90vw !important;
        max-width: 100% !important;
        max-height: 90vh;
        border-radius: 12px;
        padding: 20px;
    }

    .modal-overlay {
        padding: 16px;
    }

    .glass {
        border-radius: 12px;
    }

    .auth-container {
        min-height: auto;
        padding: 16px;
    }

    .auth-card {
        width: 90vw;
        max-width: 100%;
        padding: 20px;
        border-radius: 12px;
    }
}

/* ============================================
   RESPONSIVE PAGE HEADER
   ============================================ */

@media (max-width: 768px) {
    .page-header {
        padding: 16px;
        flex-direction: column;
        gap: 16px;
    }

    .header-actions {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: stretch;
    }

    .header-actions .btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 100px;
    }

    .breadcrumbs {
        font-size: 12px;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 8px;
    }
}

/* ============================================
   RESPONSIVE ALERTS & NOTIFICATIONS
   ============================================ */

@media (max-width: 768px) {
    .alert {
        padding: 12px;
        font-size: 13px;
        gap: 10px;
    }

    .alert i {
        font-size: 16px;
    }

    .toast-container {
        bottom: 16px;
        right: 16px;
        width: calc(100% - 32px);
    }

    .toast {
        width: 100%;
        max-width: 100%;
        border-radius: 8px;
        padding: 12px 16px;
    }
}

/* ============================================
   LOADING & SKELETON STATES
   ============================================ */

.skeleton {
    background: linear-gradient(90deg, rgba(0, 255, 255, 0.1), rgba(0, 255, 255, 0.2), rgba(0, 255, 255, 0.1));
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-large {
    height: 24px;
    margin-bottom: 12px;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 255, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 4px;
}

/* ============================================
   TOUCH & ACCESSIBILITY
   ============================================ */

/* Ensure touch targets are at least 44px */
@media (max-width: 768px) {
    a, button, [role="button"] {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Better touch feedback */
    .btn:active {
        opacity: 0.8;
    }

    /* Prevent double-tap zoom */
    input, button, select, textarea {
        font-size: 16px;
    }
}

/* ============================================
   RESPONSIVE SIDEBAR
   ============================================ */

@media (max-width: 768px) {
    .storage-info {
        padding: 16px;
        margin: 16px;
        border-radius: 8px;
    }

    .logout-btn {
        width: calc(100% - 32px);
        margin: 16px;
    }

    .sidebar-nav {
        padding: 16px 8px;
    }

    .nav-item {
        padding: 12px 14px;
        border-radius: 8px;
        font-size: 14px;
    }
}

/* ============================================
   RESPONSIVE TABLES
   ============================================ */

@media (max-width: 768px) {
    table {
        width: 100%;
        overflow-x: auto;
    }

    thead {
        display: none;
    }

    tbody, tr, td {
        display: block;
        width: 100%;
    }

    tr {
        margin-bottom: 16px;
        border: 1px solid rgba(0, 255, 255, 0.1);
        border-radius: 8px;
        padding: 12px;
    }

    td {
        padding: 8px 0;
        text-align: right;
        position: relative;
        padding-left: 50%;
    }

    td::before {
        content: attr(data-label);
        position: absolute;
        left: 8px;
        font-weight: 600;
        color: var(--gray);
        width: 40%;
        text-align: left;
    }
}

/* ============================================
   RESPONSIVE DROPDOWNS & MENUS
   ============================================ */

@media (max-width: 768px) {
    .dropdown-menu {
        position: fixed;
        top: auto;
        right: 16px;
        left: 16px;
        width: auto;
        border-radius: 12px;
        z-index: 1000;
    }

    .context-menu {
        max-width: 90vw;
        border-radius: 12px;
    }
}

/* ============================================
   RESPONSIVE UPLOADS
   ============================================ */

@media (max-width: 768px) {
    .upload-area {
        padding: 32px 16px;
        min-height: 200px;
    }

    .upload-area h3 {
        font-size: 16px;
    }

    .upload-area p {
        font-size: 12px;
    }

    .progress-bar {
        height: 6px;
    }
}

/* ============================================
   DARK MODE & COLOR ADJUSTMENTS
   ============================================ */

@media (prefers-color-scheme: dark) {
    .modal {
        background: rgba(20, 25, 40, 0.95);
    }

    .form-input,
    .form-textarea {
        background: rgba(0, 0, 0, 0.4);
        border-color: rgba(0, 255, 255, 0.2);
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Reduce motion for animations on mobile */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .btn,
    .header-actions {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    .glass {
        background: transparent;
        border: 1px solid #ddd;
    }
}
