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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
}

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

.login-box {
  background: #16213e;
  padding: 40px;
  border-radius: 10px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.login-box h1 {
  text-align: center;
  margin-bottom: 30px;
  color: #fff;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #aaa;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #333;
  border-radius: 5px;
  background: #0f0f23;
  color: #fff;
  font-size: 16px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #4a90d9;
}

.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 5px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: #4a90d9;
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background: #357abd;
}

.btn-secondary {
  background: #444;
  color: #fff;
}

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

.btn-danger {
  background: #d9534f;
  color: #fff;
}

.btn-danger:hover {
  background: #c9302c;
}

.btn-success {
  background: #5cb85c;
  color: #fff;
}

.btn-success:hover {
  background: #449d44;
}

.btn-small {
  padding: 6px 12px;
  font-size: 14px;
}

.error-message {
  background: #d9534f;
  color: #fff;
  padding: 10px 15px;
  border-radius: 5px;
  margin-bottom: 20px;
  display: none;
}

.success-message {
  background: #5cb85c;
  color: #fff;
  padding: 10px 15px;
  border-radius: 5px;
  margin-bottom: 20px;
  display: none;
}

/* Navigation */
.nav {
  background: #16213e;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.nav-brand {
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 20px;
  align-items: center;
}

.nav-links a {
  color: #aaa;
  text-decoration: none;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: #4a90d9;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 15px;
}

.nav-user span {
  color: #888;
}

/* Main layout */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Input page */
.input-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  height: calc(100vh - 100px);
}

.input-main {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.input-textarea {
  flex: 1;
  padding: 20px;
  font-size: 24px;
  border: 2px solid #333;
  border-radius: 10px;
  background: #0f0f23;
  color: #fff;
  resize: none;
}

.input-textarea:focus {
  outline: none;
  border-color: #4a90d9;
}

.input-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  gap: 5px;
  padding: 5px 10px;
  background: #16213e;
  border-radius: 5px;
}

.toolbar-btn {
  padding: 8px 12px;
  background: #333;
  border: none;
  border-radius: 3px;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
}

.toolbar-btn:hover {
  background: #444;
}

.toolbar-btn.active {
  background: #4a90d9;
}

.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 5px;
}

.color-picker {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

.input-actions {
  display: flex;
  gap: 10px;
}

.input-actions .btn {
  flex: 1;
  padding: 15px;
  font-size: 18px;
}

.char-count {
  color: #888;
  font-size: 14px;
}

/* Shortcuts sidebar */
.shortcuts-sidebar {
  background: #16213e;
  border-radius: 10px;
  padding: 15px;
  overflow-y: auto;
}

.shortcuts-sidebar h3 {
  margin-bottom: 15px;
  color: #fff;
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #0f0f23;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
}

.shortcut-item:hover {
  background: #1a1a3e;
}

.shortcut-hotkey {
  background: #4a90d9;
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: bold;
  min-width: 30px;
  text-align: center;
}

.shortcut-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Preview */
.preview-section {
  background: #16213e;
  border-radius: 10px;
  padding: 15px;
  margin-top: 15px;
}

.preview-section h3 {
  margin-bottom: 10px;
  color: #888;
  font-size: 14px;
}

.preview-content {
  padding: 20px;
  background: #000;
  border-radius: 5px;
  min-height: 100px;
  color: #fff;
  font-size: 18px;
  word-wrap: break-word;
}

/* Output page - full screen */
.output-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.output-content {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  word-wrap: break-word;
  overflow: hidden;
}

/* History page */
.history-container {
  max-width: 1000px;
  margin: 0 auto;
}

.history-search {
  margin-bottom: 20px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: #16213e;
  border-radius: 8px;
}

.history-item-content {
  flex: 1;
  word-wrap: break-word;
}

.history-item-meta {
  color: #888;
  font-size: 12px;
  margin-top: 5px;
}

.history-item-actions {
  display: flex;
  gap: 10px;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

/* Admin page */
.admin-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.admin-section {
  background: #16213e;
  border-radius: 10px;
  padding: 20px;
}

.admin-section h2 {
  margin-bottom: 20px;
  color: #fff;
  border-bottom: 1px solid #333;
  padding-bottom: 10px;
}

.bounding-box-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 20px;
}

.bounding-box {
  position: absolute;
  border: 2px dashed #4a90d9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  cursor: move;
  user-select: none;
}

.bounding-box-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #4a90d9;
  border-radius: 50%;
}

.bounding-box-handle.se {
  right: -5px;
  bottom: -5px;
  cursor: se-resize;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

/* User management */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  background: #0f0f23;
  border-radius: 5px;
}

.user-info {
  display: flex;
  gap: 15px;
  align-items: center;
}

.user-role {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
}

.user-role.admin {
  background: #d9534f;
}

.user-role.stat_user {
  background: #4a90d9;
}

.user-role.viewer {
  background: #5cb85c;
}

/* Shortcuts management page */
.shortcuts-container {
  max-width: 800px;
  margin: 0 auto;
}

.shortcut-form {
  background: #16213e;
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.shortcut-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 100px;
  gap: 15px;
  align-items: end;
}

.shortcut-manage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shortcut-manage-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: #16213e;
  border-radius: 8px;
}

.shortcut-manage-item .drag-handle {
  cursor: grab;
  color: #666;
}

.shortcut-manage-item .shortcut-info {
  flex: 1;
}

.shortcut-manage-item .shortcut-content-preview {
  color: #888;
  font-size: 14px;
  margin-top: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

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

.modal.active {
  display: flex;
}

.modal-content {
  background: #16213e;
  padding: 30px;
  border-radius: 10px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* Responsive */
@media (max-width: 900px) {
  .input-layout {
    grid-template-columns: 1fr;
  }

  .shortcuts-sidebar {
    max-height: 200px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }
}
