:root {
    --primary-color: #4F46E5;
    --primary-dark: #4338CA;
    --secondary-color: #6B7280;
    --success-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --background: #F9FAFB;
    --surface: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --sidebar-width: 280px;
    --toolbar-height: 70px;
    --border-radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent scroll when sidebar is open on mobile */
body.sidebar-open {
    overflow: hidden;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-box {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo-icon {
    width: 60px;
    height: 60px;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #4B5563;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-block {
    width: 100%;
}

.alert {
    padding: 12px 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.login-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 5px;
}

.text-warning {
    color: var(--warning-color);
    font-weight: 500;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sidebar-header .logo-icon {
    width: 32px;
    height: 32px;
    color: var(--primary-color);
}

.sidebar-header h2 {
    font-size: 18px;
    flex: 1;
}

.sidebar-toggle {
    display: none;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

.sidebar-user {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--border-radius);
    margin-bottom: 5px;
    transition: var(--transition);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--background);
    color: var(--primary-color);
}

.nav-item.active {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

.storage-info {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.storage-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.storage-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.storage-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s, background 0.3s;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
}

.toolbar {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 15px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mobile-menu-btn {
    display: none;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--border-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    padding: 0;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-icon:hover {
    background: var(--background);
    color: var(--primary-color);
}

.btn-icon.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 400px;
}

/* Search Box - ENHANCED */
.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 2;
}

.search-box input {
    width: 100%;
    padding: 10px 40px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-box.active input {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

#clearSearchBtn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    background: var(--text-secondary);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    z-index: 2;
}

#clearSearchBtn:hover {
    background: var(--text-primary);
}

/* Search Results - NEW */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-loading,
.search-error,
.search-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.search-error {
    color: var(--danger-color);
}

.search-results-list {
    padding: 5px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.search-result-item:hover {
    background: var(--background);
}

.search-result-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border-radius: var(--border-radius);
    color: var(--primary-color);
    flex-shrink: 0;
}

.search-result-icon svg {
    width: 20px;
    height: 20px;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.search-result-actions {
    display: flex;
    gap: 5px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: var(--transition);
}

.breadcrumb-item svg {
    width: 16px;
    height: 16px;
}

.breadcrumb-item:hover {
    color: var(--primary-color);
}

.breadcrumb-separator {
    color: var(--text-secondary);
}

/* Files Grid */
.files-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.file-item {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.file-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.file-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    color: var(--text-secondary);
}

.file-icon svg {
    width: 100%;
    height: 100%;
}

.folder-item .file-icon {
    color: var(--primary-color);
}

.file-icon-image {
    color: #10B981;
}

.file-icon-video {
    color: #8B5CF6;
}

.file-icon-audio {
    color: #F59E0B;
}

.file-icon-pdf {
    color: #EF4444;
}

.file-icon-archive {
    color: #6B7280;
}

.file-name {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.file-actions {
    display: flex;
    justify-content: center;
    gap: 5px;
    opacity: 0;
    transition: var(--transition);
}

.file-item:hover .file-actions {
    opacity: 1;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.05);
}

.upload-area svg {
    width: 48px;
    height: 48px;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.upload-area p {
    color: var(--text-secondary);
    font-size: 14px;
}

.upload-progress {
    margin-top: 20px;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s;
}

#progressText {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Notifications - ENHANCED */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface);
    padding: 15px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    opacity: 0;
    transform: translateX(400px);
    transition: var(--transition);
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.success {
    border-left: 4px solid var(--success-color);
}

.notification.error {
    border-left: 4px solid var(--danger-color);
}

.notification.warning {
    border-left: 4px solid var(--warning-color);
}

.notification.info {
    border-left: 4px solid var(--primary-color);
}

.notification-icon {
    font-size: 20px;
    font-weight: bold;
}

.notification.success .notification-icon {
    color: var(--success-color);
}

.notification.error .notification-icon {
    color: var(--danger-color);
}

.notification.warning .notification-icon {
    color: var(--warning-color);
}

.notification.info .notification-icon {
    color: var(--primary-color);
}

.notification-message {
    flex: 1;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== MOBILE RESPONSIVE ==================== */

@media (max-width: 768px) {
    /* Sidebar */
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        padding: 15px;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    /* Toolbar */
    .toolbar {
        padding: 12px 15px;
    }
    
    .toolbar-left {
        width: 100%;
        order: 2;
    }
    
    .toolbar-right {
        width: 100%;
        max-width: 100%;
        order: 1;
        margin-bottom: 10px;
    }
    
    /* Buttons - make them smaller on mobile */
    .btn {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .btn svg {
        width: 16px;
        height: 16px;
    }
    
    /* Search Box */
    .search-box {
        min-width: 100%;
    }
    
    /* Files Grid */
    .files-container {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }
    
    .file-item {
        padding: 15px 10px;
    }
    
    .file-icon {
        width: 36px;
        height: 36px;
    }
    
    .file-name {
        font-size: 13px;
    }
    
    .file-size {
        font-size: 11px;
    }
    
    /* Always show file actions on mobile */
    .file-actions {
        opacity: 1;
    }
    
    .file-actions .btn-icon {
        width: 32px;
        height: 32px;
    }
    
    /* Breadcrumb */
    .breadcrumb {
        font-size: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .breadcrumb-item {
        flex-shrink: 0;
    }
    
    /* Modal */
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        max-width: 100%;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .upload-area {
        padding: 30px 15px;
    }
    
    /* Login */
    .login-box {
        padding: 30px 20px;
    }
    
    /* Notifications */
    .notification {
        left: 10px;
        right: 10px;
        min-width: auto;
        max-width: none;
    }
    
    /* Storage info - hide on very small screens */
    .storage-info {
        padding: 15px;
    }
    
    .storage-header {
        font-size: 11px;
    }
    
    /* Search Results */
    .search-results {
        max-height: 300px;
    }
    
    .search-result-item {
        padding: 10px;
    }
    
    .search-result-icon {
        width: 36px;
        height: 36px;
    }
    
    .search-result-icon svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    /* Extra small devices */
    .files-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .login-header h1 {
        font-size: 24px;
    }
    
    .logo-icon {
        width: 48px;
        height: 48px;
    }
    
    .sidebar-header h2 {
        font-size: 16px;
    }
    
    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .form-actions {
        flex-direction: column-reverse;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        max-height: 100vh;
    }
    
    .files-container {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* Tablet specific */
@media (min-width: 769px) and (max-width: 1024px) {
    .files-container {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .file-item:active {
        transform: scale(0.98);
    }
    
    .btn:active {
        transform: scale(0.95);
    }
    
    .file-actions {
        opacity: 1;
    }
}

/* Prevent text selection on double-tap */
.file-item,
.btn,
.btn-icon,
.nav-item {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Better scrollbar on desktop */
@media (min-width: 769px) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    
    ::-webkit-scrollbar-track {
        background: var(--background);
    }
    
    ::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 4px;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: var(--text-secondary);
    }
}