/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  min-height: 100vh;
  line-height: 1.6;
}

.dashboard-body {
  background: #0f172a;
}

/* Login Screen */
.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: #1e293b;
  padding: 48px;
  border-radius: 20px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 1px solid #334155;
}

.login-box .logo {
  font-size: 48px;
  text-align: center;
  margin-bottom: 16px;
}

.login-box h1 {
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}

.login-box .subtitle {
  text-align: center;
  color: #64748b;
  margin-bottom: 32px;
  font-size: 14px;
}

.login-box input[type="text"],
.login-box input[type="password"] {
  width: 100%;
  padding: 14px 18px;
  margin-bottom: 16px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-box input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.login-box input::placeholder {
  color: #64748b;
}

.error-msg {
  background: #7f1d1d;
  color: #fca5a5;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  text-align: center;
}

.app-label {
  color: #94a3b8;
  font-size: 14px;
  margin-bottom: 12px;
}

.app-select {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.app-btn {
  flex: 1;
  padding: 16px 12px;
  background: #0f172a;
  border: 2px solid #334155;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.app-btn input[type="radio"] {
  display: none;
}

.app-btn .emoji {
  font-size: 24px;
}

.app-btn span:last-child {
  font-size: 13px;
  color: #94a3b8;
}

.app-btn:hover {
  border-color: #3b82f6;
  background: #1e3a5f;
}

.app-btn.active {
  border-color: #3b82f6;
  background: #1e3a5f;
}

.app-btn.active span:last-child {
  color: #e2e8f0;
}

.login-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px -10px rgba(59, 130, 246, 0.5);
}

.security-note {
  text-align: center;
  color: #64748b;
  font-size: 12px;
  margin-top: 24px;
}

/* Dashboard */
.dashboard {
  min-height: 100vh;
}

/* Header */
.header {
  background: #1e293b;
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #334155;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-switcher {
  display: flex;
  gap: 8px;
  background: #0f172a;
  padding: 4px;
  border-radius: 8px;
}

.app-switch-btn {
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 18px;
  transition: background 0.2s;
}

.app-switch-btn:hover {
  background: #334155;
}

.app-switch-btn.active {
  background: #3b82f6;
}

.app-badge {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

.user-name {
  color: #94a3b8;
  font-size: 14px;
}

.logout-btn {
  padding: 8px 16px;
  background: #ef4444;
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
}

.logout-btn:hover {
  background: #dc2626;
}

/* Main Content */
.main {
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: #1e293b;
  padding: 24px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  border: 1px solid #334155;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
}

.stat-icon {
  font-size: 32px;
  width: 60px;
  height: 60px;
  background: #0f172a;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-label {
  color: #64748b;
  font-size: 13px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #60a5fa;
}

.status-online {
  color: #22c55e !important;
}

.status-error {
  color: #ef4444 !important;
}

/* Cards */
.card {
  background: #1e293b;
  border-radius: 16px;
  border: 1px solid #334155;
  margin-bottom: 24px;
  overflow: hidden;
}

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

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.refresh-btn {
  background: #334155;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  color: #e2e8f0;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.refresh-btn:hover {
  background: #475569;
}

/* Table */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 14px 24px;
  text-align: left;
}

th {
  color: #64748b;
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #334155;
}

td {
  border-bottom: 1px solid #1e293b;
}

tr:hover td {
  background: #0f172a;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-green {
  background: #065f46;
  color: #6ee7b7;
}

.badge-blue {
  background: #1e3a5f;
  color: #60a5fa;
}

.loading {
  text-align: center;
  color: #64748b;
  padding: 40px;
}

/* Two Column Layout */
.two-column {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

/* Search */
.search-container {
  padding: 20px 24px;
}

.search-box {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.search-box input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 14px;
}

.search-box input:focus {
  outline: none;
  border-color: #3b82f6;
}

.search-box button {
  padding: 12px 24px;
  background: #3b82f6;
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.search-box button:hover {
  background: #2563eb;
}

.search-results {
  background: #0f172a;
  border-radius: 10px;
  padding: 16px;
  max-height: 250px;
  overflow-y: auto;
}

.placeholder-text {
  color: #64748b;
  text-align: center;
  padding: 20px;
}

.search-time {
  color: #22c55e;
  font-size: 12px;
  margin-bottom: 12px;
  font-weight: 500;
}

/* Documents List */
.doc-list {
  padding: 20px 24px;
  max-height: 350px;
  overflow-y: auto;
}

.doc-item {
  background: #0f172a;
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 10px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.doc-item:hover {
  border-color: #334155;
}

.doc-item .title {
  font-weight: 500;
  color: #e2e8f0;
  margin-bottom: 4px;
}

.doc-item .abstract {
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

/* Charts */
.chart-container {
  padding: 24px;
  height: 300px;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  color: #475569;
  font-size: 13px;
  border-top: 1px solid #334155;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #1e293b;
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border: 1px solid #334155;
  overflow: hidden;
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: #334155;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s;
}

.modal-close:hover {
  background: #ef4444;
}

.modal-search {
  padding: 16px 24px;
  display: flex;
  gap: 12px;
  border-bottom: 1px solid #334155;
}

.modal-search input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 14px;
}

.modal-search input:focus {
  outline: none;
  border-color: #3b82f6;
}

.modal-search button {
  padding: 10px 20px;
  background: #3b82f6;
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  cursor: pointer;
}

.modal-stats {
  padding: 12px 24px;
  background: #0f172a;
  font-size: 13px;
  color: #94a3b8;
  display: flex;
  gap: 20px;
}

.modal-stats span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-stats .count {
  color: #60a5fa;
  font-weight: 600;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.modal-doc-item {
  background: #0f172a;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid #334155;
}

.modal-doc-item:hover {
  border-color: #3b82f6;
}

.modal-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-doc-title {
  font-weight: 600;
  color: #e2e8f0;
  font-size: 15px;
  flex: 1;
  word-break: break-word;
}

.modal-doc-id {
  font-size: 11px;
  color: #64748b;
  background: #334155;
  padding: 2px 8px;
  border-radius: 4px;
}

.modal-doc-content {
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.6;
}

.modal-doc-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-doc-tag {
  font-size: 11px;
  background: #1e3a5f;
  color: #60a5fa;
  padding: 3px 8px;
  border-radius: 4px;
}

.modal-pagination {
  padding: 16px 24px;
  border-top: 1px solid #334155;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.modal-pagination button {
  padding: 8px 16px;
  background: #334155;
  border: none;
  border-radius: 6px;
  color: #e2e8f0;
  cursor: pointer;
  font-size: 13px;
}

.modal-pagination button:hover {
  background: #475569;
}

.modal-pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-pagination .page-info {
  padding: 8px 16px;
  color: #94a3b8;
  font-size: 13px;
}

/* Clickable index row */
.index-row {
  cursor: pointer;
  transition: background 0.2s;
}

.index-row:hover td {
  background: #1e3a5f !important;
}

.index-name-link {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 600;
}

.index-name-link:hover {
  text-decoration: underline;
}

/* Storage Calculator */
.calculator-container {
  padding: 24px;
}

.calculator-info {
  margin-bottom: 20px;
}

.calculator-info p {
  color: #94a3b8;
  margin-bottom: 8px;
}

.calculator-info strong {
  color: #60a5fa;
  font-size: 18px;
}

.calculator-note {
  font-size: 13px;
  color: #64748b !important;
}

.calculator-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.calc-input-group {
  background: #0f172a;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid #334155;
}

.calc-input-group label {
  display: block;
  color: #94a3b8;
  font-size: 12px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.calc-input-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 16px;
  font-weight: 600;
}

.calc-input-group input:focus {
  outline: none;
  border-color: #3b82f6;
}

.calc-input-group .current-count {
  font-size: 11px;
  color: #64748b;
  margin-top: 6px;
}

.calculator-result {
  display: flex;
  align-items: stretch;
  gap: 20px;
  flex-wrap: wrap;
}

.calculator-result .calc-btn {
  align-self: flex-start;
}

.calc-btn {
  padding: 12px 24px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.calc-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px -10px rgba(59, 130, 246, 0.5);
}

.estimate-result {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 20px 28px;
  border-radius: 14px;
  border: 1px solid #334155;
  flex: 1;
  min-width: 280px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.estimate-label {
  color: #64748b;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: block;
}

.estimate-value {
  color: #22c55e;
  font-size: 32px;
  font-weight: 700;
  display: block;
  text-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.estimate-breakdown {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #334155;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.estimate-breakdown-item {
  background: #1e3a5f;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: #60a5fa;
}

.estimate-breakdown-item span {
  color: #94a3b8;
}

/* Delete Button & Modal */
.modal-doc-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.delete-doc-btn {
  background: transparent;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  opacity: 0.6;
}

.delete-doc-btn:hover {
  background: #7f1d1d;
  border-color: #ef4444;
  opacity: 1;
}

.modal-doc-item:hover .delete-doc-btn {
  opacity: 1;
}

/* Delete Confirmation Modal */
.delete-confirm-overlay {
  z-index: 1100;
}

.delete-confirm-box {
  background: #1e293b;
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  border: 1px solid #334155;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.delete-confirm-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.delete-confirm-box h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #e2e8f0;
}

.delete-confirm-text {
  color: #94a3b8;
  margin-bottom: 20px;
  font-size: 14px;
}

.delete-doc-info {
  background: #0f172a;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid #334155;
}

.delete-doc-title {
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 6px;
  word-break: break-word;
}

.delete-doc-id {
  font-size: 12px;
  color: #64748b;
}

.delete-doc-id span {
  color: #94a3b8;
  font-family: monospace;
}

.delete-warning {
  color: #ef4444;
  font-size: 13px;
  margin-bottom: 24px;
  font-weight: 500;
}

.delete-confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.cancel-btn {
  padding: 12px 24px;
  background: #334155;
  border: none;
  border-radius: 8px;
  color: #e2e8f0;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.cancel-btn:hover {
  background: #475569;
}

.confirm-delete-btn {
  padding: 12px 24px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.confirm-delete-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px -10px rgba(239, 68, 68, 0.5);
}

.confirm-delete-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Fade out animation for deleted items */
@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-20px);
  }
}

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

  .header-right {
    flex-wrap: wrap;
    justify-content: center;
  }

  .main {
    padding: 16px;
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .login-box {
    padding: 32px 24px;
  }

  .app-select {
    flex-direction: column;
  }
}
