/* ── Media page layout ───────────────────────────────────────────────────── */

.media-page {
  background: #faf7f4;
  min-height: 100vh;
}

.media-wrapper {
  display: flex;
  height: calc(100vh - 64px);
  margin-top: 64px;
  overflow: hidden;
}

/* ── Auth / Drive overlays ───────────────────────────────────────────────── */

.auth-check-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 64px);
  margin-top: 64px;
}

.auth-check-content {
  text-align: center;
}

.drive-auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(250, 247, 244, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.drive-auth-overlay.hidden { display: none; }

.drive-auth-content {
  text-align: center;
  max-width: 380px;
  padding: 2rem;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.drive-auth-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.drive-auth-content h2 {
  color: #5d4c3c;
  margin: 0 0 0.75rem;
}

.drive-auth-content p {
  color: #888;
  font-size: 14px;
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

.drive-connect-btn {
  background: #5d4c3c;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 28px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}

.drive-connect-btn:hover { background: #7a6855; }

/* ── Left sidebar ────────────────────────────────────────────────────────── */

.media-sidebar {
  width: 280px;
  min-width: 220px;
  max-width: 320px;
  background: #fff;
  border-right: 1px solid #e5ded5;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.media-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #f0ebe4;
}

.media-sidebar-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: #5d4c3c;
  margin: 0;
}

.new-ticket-btn {
  background: #5d4c3c;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.new-ticket-btn:hover { background: #7a6855; }

.media-folder-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.media-folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}

.media-folder-item:hover {
  background: #faf7f4;
}

.media-folder-item.active {
  background: #f5efe8;
  border-left-color: #7a6855;
}

.media-folder-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.media-folder-info {
  flex: 1;
  min-width: 0;
}

.media-folder-name {
  font-size: 13px;
  font-weight: 600;
  color: #5d4c3c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-folder-meta {
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
}

.media-folder-count {
  font-size: 11px;
  color: #bbb;
  background: #f0ebe4;
  border-radius: 10px;
  padding: 2px 7px;
  flex-shrink: 0;
}

/* ── Main content area ───────────────────────────────────────────────────── */

.media-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.media-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #bbb;
  gap: 12px;
}

.media-placeholder-icon { font-size: 4rem; }
.media-placeholder p { font-size: 15px; }

.media-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.media-content.hidden { display: none; }

/* ── Content header ──────────────────────────────────────────────────────── */

.media-content-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid #e5ded5;
  background: #fff;
  flex-shrink: 0;
}

.media-content-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.media-content-title h2 {
  font-size: 16px;
  font-weight: 700;
  color: #5d4c3c;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drive-link {
  font-size: 12px;
  color: #7a6855;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.drive-link:hover { opacity: 1; }

/* ── Upload zone ─────────────────────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed #d5c9be;
  border-radius: 10px;
  background: #faf7f4;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
  min-height: 64px;
}

.upload-zone.drag-over {
  border-color: #7a6855;
  background: #f5efe8;
}

.upload-zone-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  flex-wrap: wrap;
}

.upload-icon { font-size: 20px; }

.upload-label {
  font-size: 13px;
  color: #7a6855;
}

.upload-browse-btn {
  background: none;
  border: none;
  color: #5d4c3c;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
  padding: 0;
}

.upload-hint {
  font-size: 11px;
  color: #bbb;
  width: 100%;
  text-align: center;
  margin-top: -4px;
}

.upload-progress {
  padding: 12px 16px;
}

.upload-progress.hidden { display: none; }

.upload-progress-bar-wrap {
  background: #e5ded5;
  border-radius: 4px;
  height: 6px;
  margin-bottom: 6px;
}

.upload-progress-bar {
  background: #7a6855;
  border-radius: 4px;
  height: 6px;
  width: 0%;
  transition: width 0.2s;
}

.upload-progress-label {
  font-size: 12px;
  color: #7a6855;
}

/* ── File grid ───────────────────────────────────────────────────────────── */

.media-file-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  align-content: start;
}

.media-loading {
  color: #bbb;
  font-size: 14px;
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 0;
}

.media-empty {
  color: #bbb;
  font-size: 14px;
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 0;
}

/* ── File card ───────────────────────────────────────────────────────────── */

.media-file-card {
  background: #fff;
  border: 1px solid #e5ded5;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s, transform 0.1s;
  cursor: grab;
}

.media-file-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  transform: translateY(-2px);
}

.media-file-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.media-file-card.drag-over {
  border-color: #7a6855;
  box-shadow: 0 0 0 2px #7a6855;
}

/* Thumbnail */
.media-file-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #f0ebe4;
  display: block;
}

.media-file-thumb-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: #f0ebe4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

/* Card body */
.media-file-body {
  padding: 10px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.media-file-name {
  font-size: 12px;
  font-weight: 600;
  color: #5d4c3c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-file-size {
  font-size: 11px;
  color: #bbb;
}

.media-file-note {
  font-size: 12px;
  color: #7a6855;
  border: none;
  border-bottom: 1px solid transparent;
  background: none;
  width: 100%;
  resize: none;
  padding: 2px 0;
  font-family: inherit;
  transition: border-color 0.15s;
  min-height: 32px;
}

.media-file-note:focus {
  outline: none;
  border-bottom-color: #7a6855;
}

.media-file-note::placeholder {
  color: #ccc;
  font-style: italic;
}

/* Card actions */
.media-file-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid #f0ebe4;
}

.media-file-btn {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid #e5ded5;
  border-radius: 5px;
  background: #faf7f4;
  color: #5d4c3c;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.media-file-btn:hover {
  background: #f0ebe4;
}

.media-file-btn.delete-btn:hover {
  background: #fdecea;
  border-color: #e57373;
  color: #c0392b;
}

/* ── New Ticket Modal ────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5ded5;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  color: #5d4c3c;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: #aaa;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12px;
  font-weight: 700;
  color: #7a6855;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  border: 1px solid #e5ded5;
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 14px;
  color: #5d4c3c;
  background: #faf7f4;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus {
  border-color: #7a6855;
  background: #fff;
}

.modal-hint {
  font-size: 12px;
  color: #aaa;
  margin: 0;
  background: #faf7f4;
  border-radius: 6px;
  padding: 8px 12px;
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #e5ded5;
}

.btn-primary {
  background: #5d4c3c;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: #7a6855; }

.btn-secondary {
  background: #f0ebe4;
  color: #5d4c3c;
  border: none;
  border-radius: 7px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: #e5ded5; }

/* ── Mobile responsive ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .media-wrapper {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 64px);
    padding-bottom: 70px;
  }

  .media-sidebar {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 220px;
    border-right: none;
    border-bottom: 1px solid #e5ded5;
  }

  .media-folder-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 8px;
    gap: 6px;
  }

  .media-folder-item {
    flex-direction: column;
    align-items: center;
    min-width: 90px;
    padding: 8px 10px;
    border-left: none;
    border-bottom: 3px solid transparent;
    border-radius: 8px;
    text-align: center;
    gap: 4px;
  }

  .media-folder-item.active {
    border-left-color: transparent;
    border-bottom-color: #7a6855;
  }

  .media-folder-name {
    font-size: 11px;
    white-space: normal;
    word-break: break-word;
    text-align: center;
  }

  .media-main {
    flex: 1;
  }

  .media-file-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    padding: 12px;
  }

  .media-content-header {
    padding: 12px;
  }
}
