/* PhotoServer Styles */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --danger-color: #dc2626;
  --danger-hover: #b91c1c;
  --secondary-color: #6b7280;
  --secondary-hover: #4b5563;
  --bg-color: #f3f4f6;
  --card-bg: #ffffff;
  --text-color: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: white;
}

.btn-secondary:hover {
  background-color: var(--secondary-hover);
}

.btn-danger {
  background-color: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background-color: var(--danger-hover);
}

.btn-warning {
  background-color: #f59e0b;
  color: white;
}

.btn-warning:hover {
  background-color: #d97706;
}

/* Button loading state */
.btn.btn-loading {
  pointer-events: none;
  opacity: 0.85;
  position: relative;
}

.btn.btn-loading .btn-text {
  visibility: hidden;
}

.btn.btn-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Screen Management */
.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* Login Screen */
.login-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 2rem;
  padding-top: 15vh;
  text-align: center;
}

.login-container h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.login-container p {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.code-input-container {
  margin-bottom: 1.5rem;
}

#code-input {
  width: 200px;
  padding: 1rem;
  font-size: 2rem;
  text-align: center;
  letter-spacing: 0.5rem;
  border: 2px solid var(--border-color);
  border-radius: 0.5rem;
  outline: none;
  transition: border-color 0.2s;
}

#code-input:focus {
  border-color: var(--primary-color);
}

#login-form .btn {
  width: 200px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.error-message {
  color: var(--danger-color);
  margin-top: 1rem;
  font-size: 0.875rem;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 1.25rem;
}

.header-right {
  display: flex;
  gap: 0.5rem;
}

/* Breadcrumbs */
.breadcrumbs {
  padding: 0.75rem 2rem;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  position: sticky;
  z-index: 99;
}

.breadcrumbs a {
  color: var(--primary-color);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.breadcrumbs span {
  color: var(--text-muted);
  margin: 0 0.5rem;
}

/* Selection Bar */
.selection-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 2rem;
  background-color: var(--primary-color);
  color: white;
}

#selection-count {
  flex: 1;
}

/* File Grid */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
}

/* File Item */
.file-item {
  background-color: var(--card-bg);
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.file-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.file-item.selected {
  outline: 3px solid var(--primary-color);
}

.file-item .checkbox {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 24px;
  height: 24px;
  background-color: white;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.file-item .checkbox.checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.file-item .checkbox.checked::after {
  content: '✓';
  color: white;
  font-weight: bold;
}

.select-mode .file-item .checkbox {
  display: flex;
}

.file-thumbnail {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background-color: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-thumbnail .icon {
  font-size: 3rem;
  color: var(--text-muted);
}

.file-info {
  padding: 0.75rem;
}

.file-name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Folder Item */
.file-item.folder .file-thumbnail {
  background-color: #fef3c7;
}

.file-item.folder .icon {
  color: #d97706;
}

/* Video Play Icon */
.file-item.video .file-thumbnail::after {
  content: '▶';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.file-item.video .file-thumbnail {
  position: relative;
}

/* Loading Indicator */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Lightbox */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  outline: none;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 2rem;
  color: white;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1001;
  padding: 0.5rem;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  cursor: pointer;
  padding: 1rem;
  z-index: 1001;
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

.lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  min-height: 0;
  overflow: hidden;
}

.lightbox-content img,
.lightbox-content video {
  max-width: calc(100vw - 8rem);
  max-height: calc(100vh - 12rem);
  object-fit: contain;
}

.lightbox-content img.hidden,
.lightbox-content video.hidden {
  display: none;
}

.lightbox-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
}

#lightbox-filename {
  font-size: 0.875rem;
}

/* Contact Button */
.btn-contact {
  background: linear-gradient(135deg, #0078d4, #00a4ef);
  color: white;
  font-size: 1.4rem;
  font-weight: 600;
  padding: 1.1rem 2.75rem;
  border-radius: 0.5rem;
  letter-spacing: 0.01em;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0, 120, 212, 0.35);
}

.btn-contact:hover {
  background: linear-gradient(135deg, #106ebe, #0078d4);
  box-shadow: 0 4px 12px rgba(0, 120, 212, 0.45);
  animation: none;
}

.btn-contact:active {
  transform: scale(0.98);
}

@keyframes contact-attention {
  0% {
    box-shadow: 0 2px 8px rgba(0, 120, 212, 0.35);
    transform: rotate(0deg);
  }
  1% { transform: rotate(-3deg); box-shadow: 0 0 15px rgba(0, 164, 239, 0.6); }
  2% { transform: rotate(3deg); }
  3% { transform: rotate(-3deg); box-shadow: 0 0 25px rgba(0, 164, 239, 0.8); }
  4% { transform: rotate(3deg); }
  5% { transform: rotate(-2deg); }
  6% { transform: rotate(2deg); box-shadow: 0 0 15px rgba(0, 164, 239, 0.6); }
  7% {
    box-shadow: 0 2px 8px rgba(0, 120, 212, 0.35);
    transform: rotate(0deg);
  }
  100% {
    box-shadow: 0 2px 8px rgba(0, 120, 212, 0.35);
    transform: rotate(0deg);
  }
}

/* Contact Overlay */
.contact-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.contact-window {
  background: #ffffff;
  width: 100%;
  max-width: 640px;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 90vh;
}

.contact-titlebar {
  background: #0078d4;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.contact-titlebar-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.contact-titlebar-close:hover {
  opacity: 0.8;
}

.contact-call-banner {
  background: #0078d4;
  color: white;
  text-align: center;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.contact-toolbar {
  background: #f3f2f1;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #edebe9;
}

.contact-send-btn {
  background: #0078d4;
  color: white;
  border: none;
  padding: 0.4rem 1.5rem;
  border-radius: 3px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.contact-send-btn:hover {
  background: #106ebe;
}

.contact-send-btn:disabled {
  background: #c8c6c4;
  cursor: not-allowed;
}

.contact-fields {
  padding: 0 1rem;
}

.contact-field-row {
  display: flex;
  align-items: center;
  padding: 0.5rem 0;
  gap: 0.75rem;
}

.contact-label {
  font-size: 0.85rem;
  color: #605e5c;
  min-width: 50px;
  font-weight: 500;
}

.contact-to-value {
  font-size: 0.85rem;
  color: #0078d4;
  font-weight: 500;
}

.contact-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.85rem;
  color: #323130;
  padding: 0.15rem 0;
  font-family: inherit;
}

.contact-input::placeholder {
  color: #a19f9d;
}

.contact-divider {
  border-bottom: 1px solid #edebe9;
}

.contact-body {
  flex: 1;
  min-height: 200px;
  border: none;
  outline: none;
  padding: 1rem;
  font-size: 0.9rem;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color: #323130;
  resize: none;
  line-height: 1.5;
}

.contact-body::placeholder {
  color: #a19f9d;
}

.contact-footer {
  padding: 0.5rem 1rem;
  border-top: 1px solid #edebe9;
  background: #faf9f8;
  font-size: 0.8rem;
  color: #605e5c;
}

.contact-phone {
  font-weight: 500;
}

.contact-status {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  text-align: center;
}

.contact-status.success {
  background: #dff6dd;
  color: #107c10;
}

.contact-status.error {
  background: #fde7e9;
  color: #a4262c;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }

  .header-right {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .header-right .btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.6rem;
  }

  .header-right .btn-contact {
    font-size: 0.95rem;
    padding: 0.6rem 1.2rem;
  }

  .header h1 {
    font-size: 1rem;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    padding: 0.75rem;
  }

  .breadcrumbs {
    padding: 0.5rem 0.75rem;
  }

  .selection-bar {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }

  .lightbox-nav {
    padding: 0.5rem;
    font-size: 1.5rem;
  }

  .lightbox-content {
    padding: 1rem;
  }

  .lightbox-content img,
  .lightbox-content video {
    max-width: calc(100vw - 2rem);
    max-height: calc(100vh - 8rem);
  }

  .contact-window {
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}
