/* ===== THEME & VARIABLES ===== */
:root { --font-family: 'Inter', -apple-system, sans-serif; --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px; --transition-speed: 0.2s; }
body { --bg-primary: #ffffff; --bg-secondary: #f5f5f5; --bg-tertiary: #ebebeb; --bg-contrast: #000000; --text-primary: #000000; --text-secondary: #525252; --text-on-contrast: #ffffff; --border: #d4d4d4; --accent: #ff453a; }
body.dark-theme { --bg-primary: #000000; --bg-secondary: #1c1c1e; --bg-tertiary: #2c2c2e; --bg-contrast: #ffffff; --text-primary: #ffffff; --text-secondary: #8e8e93; --text-on-contrast: #000000; --border: #38383a; --accent: #ff453a; }

/* ===== GENERAL & BASE STYLES ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-family); background-color: var(--bg-primary); color: var(--text-primary); font-size: 14px; -webkit-font-smoothing: antialiased; }
.page { width: 100vw; height: 100vh; overflow: hidden; }
a { color: var(--text-on-contrast); text-decoration: none; }
button, .button, label { cursor: pointer; border: none; background: none; font-family: var(--font-family); color: inherit; }
input, select { font-family: var(--font-family); font-size: 14px; border-radius: var(--radius-md); border: 1px solid var(--border); width: 100%; padding: 10px 12px; background-color: var(--bg-tertiary); color: var(--text-primary); outline: none; }
hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
ion-icon { vertical-align: middle; font-size: 1.25rem; }
.icon-btn { padding: 6px; line-height: 1; border-radius: var(--radius-md); transition: background-color var(--transition-speed); color: var(--text-secondary); }
.icon-btn:hover { background-color: var(--bg-tertiary); color: var(--text-primary); }

/* ===== AUTH PAGES ===== */
.auth-page { display: flex; justify-content: center; align-items: center; background-color: var(--bg-primary); }
.auth-box { width: 90%; max-width: 380px; text-align: center; }
.auth-box h1 { font-size: 28px; margin-bottom: 8px; color: var(--text-primary); }
.auth-box p { color: var(--text-secondary); margin-bottom: 24px; }
.auth-box form { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
.auth-box form button { background-color: var(--bg-contrast); color: var(--text-on-contrast); padding: 12px; font-weight: 600; border-radius: var(--radius-md); }
.auth-switch { font-size: 14px; color: var(--text-secondary); }
.auth-switch a { color: var(--text-primary); font-weight: 500; }

/* ===== DRIVE LAYOUT ===== */
#drive-page { display: flex; }
#sidebar { width: 280px; background-color: var(--bg-secondary); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px; z-index: 110; flex-shrink: 0; }
.sidebar-header h2 { font-size: 20px; font-weight: 600; margin-bottom: 24px; padding-left: 4px; }
.sidebar-actions { margin-bottom: 24px; position: relative; }
.sidebar-actions > button { background-color: var(--bg-contrast); color: var(--text-on-contrast); width: 100%; padding: 12px; font-size: 15px; font-weight: 500; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; gap: 8px; }
#sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { width: 100%; justify-content: flex-start; text-align: left; font-weight: 500; font-size: 15px; padding: 10px 12px; gap: 12px; position: relative; display: flex; align-items: center; border-radius: var(--radius-lg); }
.nav-item:hover { background-color: var(--bg-tertiary); }
.nav-item.active { background-color: var(--bg-contrast); color: var(--text-on-contrast); }
.nav-item-badge { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); background-color: var(--accent); width: 8px; height: 8px; border-radius: 50%; display: none; }
#storage-quota-widget { margin-top: auto; padding: 16px 4px 0; font-size: 13px; color: var(--text-secondary); }
.storage-text { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.storage-text #storage-usage-text { margin-left: auto; }
.storage-bar { width: 100%; height: 6px; background-color: var(--bg-tertiary); border-radius: 3px; overflow: hidden; }
#storage-bar-fill { height: 100%; width: 0%; background-color: var(--text-secondary); border-radius: 3px; transition: width 0.5s; }
.sidebar-footer { padding-top: 20px; }
.user-profile { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; font-weight: 500; }
#user-email { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.footer-actions { display: flex; gap: 4px; }
#content-wrapper { flex-grow: 1; display: flex; height: 100vh; overflow: hidden; }
#main-content { flex-grow: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ===== MAIN CONTENT ===== */
.main-header { padding: 12px 24px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 16px; }
#breadcrumbs { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.breadcrumb-link { color: var(--text-secondary); text-decoration: none; } .breadcrumb-link:hover { color: var(--text-primary); }
.header-controls { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.search-box { position: relative; flex-grow: 1; }
.search-box ion-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: 1.1rem; }
#search-input { padding: 8px 12px 8px 36px; background-color: var(--bg-tertiary); border-color: var(--bg-tertiary); } #search-input:focus { border-color: var(--border); }
.view-toggle { display: flex; background-color: var(--bg-tertiary); padding: 4px; border-radius: var(--radius-md); }
.view-toggle .icon-btn.active { background-color: var(--bg-primary); }
#file-list-header { font-weight: 500; color: var(--text-secondary); padding: 4px 24px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; display: grid; grid-template-columns: 1fr 150px 150px 180px; align-items: center; gap: 16px; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.item-name-header { padding-left: 44px; }
#file-container-wrapper { flex-grow: 1; overflow-y: auto; padding: 0 24px; position: relative; }
#file-container-wrapper:focus { outline: none; }
#status-bar { padding: 8px 24px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }

/* FILE ITEMS (GRID & LIST) */
.file-item { display: grid; align-items: center; cursor: pointer; user-select: none; border-bottom: 1px solid var(--border); position: relative; }
.file-item:hover { background-color: var(--bg-secondary); }
.file-item.selected { background-color: var(--bg-tertiary); }
.file-item.drag-over { background-color: var(--bg-tertiary); border-style: dashed; border-color: var(--text-primary); }
.item-icon { font-size: 20px; color: var(--text-secondary); }
.item-name { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-weight: 500; display: flex; align-items: center; gap: 16px; }
#file-container.file-list { display: flex; flex-direction: column; }
.file-list .file-item { grid-template-columns: 1fr 150px 150px 180px; gap: 16px; padding: 14px 0; }
.file-list .item-size-col, .file-list .item-date-col, .file-list .item-owner-col { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#file-container.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; padding: 16px 0; }
.file-grid .file-item { flex-direction: column; height: 120px; text-align: center; padding: 16px 8px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.file-grid .item-name { flex-direction: column; gap: 0; }
.file-grid .item-icon { font-size: 40px; margin-bottom: 12px; }
.file-grid .item-size-col, .file-grid .item-date-col, .file-grid .item-owner-col { display: none; }
#empty-folder-message { text-align: center; padding-top: 80px; color: var(--text-secondary); } #empty-folder-message ion-icon { font-size: 48px; } #empty-folder-message p { font-size: 16px; font-weight: 500; margin: 8px 0; }
#selection-box { position: absolute; background-color: rgba(255, 255, 255, 0.1); border: 1px solid var(--text-primary); z-index: 100; pointer-events: none; }

/* DETAILS PANEL */
#details-panel { width: 300px; border-left: 1px solid var(--border); background-color: var(--bg-secondary); flex-shrink: 0; padding: 16px; overflow-y: auto; transition: width 0.2s, padding 0.2s; }
#details-panel.collapsed { width: 0; padding: 0; overflow: hidden; border-left: none; }
#details-placeholder { text-align: center; color: var(--text-secondary); padding-top: 50px; } #details-placeholder ion-icon { font-size: 48px; } #details-placeholder p { margin-top: 8px; }
#details-header { text-align: center; margin-bottom: 24px; word-wrap: break-word; }
#details-header #details-icon { font-size: 48px; margin-bottom: 12px; }
#details-header #details-name { font-size: 16px; font-weight: 600; }
.details-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 24px; }
.details-action-btn { background-color: var(--bg-tertiary); border: none; padding: 8px; border-radius: var(--radius-md); display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--text-primary); }
.details-action-btn ion-icon { font-size: 20px; } .details-action-btn:hover { background-color: var(--border); }
.details-properties h4 { font-size: 14px; margin-bottom: 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.prop-item { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 10px; }
.prop-item span:first-child { color: var(--text-secondary); }

/* PANELS, MODALS, & NOTIFICATIONS */
.panel { position: fixed; z-index: 10002; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 8px 24px rgba(0,0,0,0.2); width: 320px; max-height: 400px; display: none; flex-direction: column; }
#notification-panel { bottom: 70px; right: 20px; padding: 8px; }
#notification-panel h3 { padding: 8px 8px 12px; font-size: 16px; font-weight: 600; }
#notification-list { flex-grow: 1; overflow-y: auto; }
.notification-item { padding: 8px 8px; font-size: 14px; border-radius: var(--radius-sm); }
.notification-item.unread { font-weight: 500; }
.modal-overlay, .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
.modal-overlay { z-index: 1000; background-color: rgba(0,0,0,0.5); backdrop-filter: blur(4px); }
.modal { z-index: 1001; justify-content: center; align-items: center; padding: 16px; }
.modal.show, .modal-overlay.show, .panel.show { display: flex; }
.modal-content { background-color: var(--bg-secondary); padding: 24px; border-radius: var(--radius-lg); width: 100%; max-width: 450px; border: 1px solid var(--border); position: relative; display: flex; flex-direction: column; gap: 16px; }
.modal-content .close-btn { position: absolute; top: 12px; right: 12px; }
.modal-content button { background-color: var(--bg-contrast); color: var(--text-on-contrast); padding: 10px; border-radius: var(--radius-md); font-weight: 500; }
#notification-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; }
.notification, .undo-toast { background-color: var(--bg-tertiary); color: var(--text-primary); padding: 12px 20px; border-radius: var(--radius-md); display: flex; align-items: center; gap: 20px; transition: all 0.4s ease; box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
#undo-toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 150%); } #undo-toast.show { transform: translate(-50%, 0); }
.undo-toast button { background-color: var(--bg-contrast); color: var(--text-on-contrast); padding: 6px 12px; border-radius: var(--radius-sm); }
.notification { transform: translateX(120%); opacity: 0; margin-top: 10px; } .notification.show { transform: translateX(0); opacity: 1; }
.context-menu { position: fixed; z-index: 10001; width: 220px; background: var(--bg-tertiary); border-radius: var(--radius-md); box-shadow: 0 4px 16px rgba(0,0,0,0.2); border: 1px solid var(--border); padding: 6px; display: none; }
.context-menu-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); font-size: 14px; cursor: pointer; }
.context-menu-item:hover { background-color: var(--bg-contrast); color: var(--text-on-contrast); }
.context-menu-item.danger:hover { background-color: var(--accent); color: white; }

/* EDITOR & LIGHTBOX */
.editor-modal .modal-content { width: 95%; max-width: 900px; height: 90vh; transition: all var(--transition-speed); }
.editor-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); flex-shrink: 0; padding-bottom: 12px; margin: 0; }
.editor-controls { display: flex; align-items: center; gap: 8px; }
#quill-editor-container, #codemirror-container { flex-grow: 1; height: 0; margin-top: 16px; }
.ql-toolbar.ql-snow { border: 1px solid var(--border); border-bottom: none; background-color: var(--bg-primary); border-top-left-radius: var(--radius-md); border-top-right-radius: var(--radius-md); }
.ql-snow .ql-stroke { stroke: var(--text-secondary); } .ql-snow .ql-picker-label { color: var(--text-secondary); } .ql-snow .ql-fill { fill: var(--text-secondary); }
.ql-container.ql-snow { border: 1px solid var(--border); background-color: var(--bg-primary); } .ql-editor { color: var(--text-primary); }
.CodeMirror { height: 100%; border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 14px; }
body:not(.dark-theme) .CodeMirror { background: var(--bg-primary); } body.dark-theme .CodeMirror { background-color: #1c1c1e; }
body.dark-theme .CodeMirror-gutters { background-color: #1c1c1e; border-right-color: var(--border); }
.editor-modal.fullscreen { padding: 0; } .editor-modal.fullscreen .modal-content { max-width: 100%; height: 100vh; max-height: 100vh; border-radius: 0; }
.lightbox { background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); }
.lightbox img, .lightbox iframe { max-width: 90vw; max-height: 90vh; border-radius: var(--radius-md); border: none; }
.lightbox #preview-iframe { width: 90vw; height: 90vh; background-color: white; }
.lightbox-close { position: fixed; top: 20px; right: 20px; font-size: 2rem; color: white; background: rgba(0,0,0,0.3); }

/* RESPONSIVE */
.mobile-only { display: none; }
@media (max-width: 992px) { #sidebar { position: fixed; height: 100%; margin-left: -280px; } #sidebar.open { margin-left: 0; box-shadow: 10px 0 20px rgba(0,0,0,0.1); } #details-panel { display: none; } .mobile-only { display: block; } }
@media (max-width: 768px) { .file-list .item-owner-col, #file-list-header .item-owner-header { display: none; } .file-list .file-item, #file-list-header { grid-template-columns: 1fr 120px 150px; } }
@media (max-width: 576px) { .file-list .item-date-col, #file-list-header .item-date-header { display: none; } .file-list .file-item, #file-list-header { grid-template-columns: 1fr 100px; } }