:root {
  /* Light mode colors */
  --primary-color: #2c3e50;
  --secondary-color: #34495e;
  --accent-color: #3498db;
  --text-color: #2c3e50;
  --background-color: #ecf0f1;
  --card-background: #ffffff;
  --border-color: #e0e0e0;
  --hover-background: rgba(248, 249, 250, 0.8);
  --focus-background: rgba(248, 249, 250, 1);
}

[data-theme="dark"] {
  --primary-color: #ecf0f1;
  --secondary-color: #bdc3c7;
  --accent-color: #3498db;
  --text-color: #ecf0f1;
  --background-color: #2c3e50;
  --card-background: #34495e;
  --border-color: #486683;
  --hover-background: rgba(52, 73, 94, 0.8);
  --focus-background: rgba(52, 73, 94, 1);
}

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

body {
  font-family: "Courier New", Courier, monospace;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background-color);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

h1 {
  text-align: center;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.upload-section {
  margin: 1rem auto 2rem;
  padding: 1.5rem;
  background-color: var(--card-background);
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  display: flex;
  gap: 1.5rem;
  align-items: center;
  max-width: 1100px;
}

.upload-section > div {
  flex: 1;
}

.upload-section label {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.upload-section input[type="file"] {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--card-background);
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.3s ease;
}

.upload-section input[type="file"]:hover {
  border-color: var(--accent-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.upload-section select {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--card-background);
  color: var(--text-color);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  transition: all 0.3s ease;
}

.upload-section select:hover,
.upload-section select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.upload-section button {
  height: 45px;
  padding: 0 2rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-color), #2980b9);
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.upload-section button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  background: linear-gradient(135deg, #2980b9, var(--accent-color));
}

.upload-section button:disabled {
  background: linear-gradient(135deg, #bdc3c7, #95a5a6);
  opacity: 0.8;
}

.options-section {
  display: none;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

input[type="file"],
select {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--card-background);
  color: var(--text-color);
}

select {
  font-family: "Courier New", Courier, monospace;
}

button {
  background-color: var(--accent-color);
  color: white;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

button:disabled {
  background-color: #bdc3c7;
  cursor: not-allowed;
}

button:hover:not(:disabled) {
  background-color: #2980b9;
}

.preview-section {
  display: flex;
  gap: 1rem;
  background-color: var(--card-background);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: relative;
}

.preview-content {
  flex: 1;
  min-height: 800px;
}

.formatting-toolbar {
  position: sticky;
  top: 2rem;
  width: 44px;
  background: var(--card-background);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 1px solid var(--accent-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  height: fit-content;
}

.formatting-toolbar button,
.top-formatting-toolbar button {
  width: 30px;
  height: 30px;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid var(--accent-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--accent-color);
}

.formatting-toolbar button:hover,
.top-formatting-toolbar button:hover {
  background: var(--accent-color);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.formatting-toolbar button svg,
.top-formatting-toolbar button svg {
  width: 18px;
  height: 18px;
}

.formatting-toolbar hr,
.top-formatting-toolbar hr {
  border: none;
  border-left: 2px solid var(--accent-color);
  height: 24px;
  margin: 0 0.5rem;
  opacity: 0.5;
}

.top-formatting-toolbar {
  background: var(--card-background);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--accent-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: none; 
}

.top-formatting-toolbar.visible {
  display: flex;
}

.action-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.action-buttons button {
  background-color: var(--accent-color);
  color: white;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.action-buttons button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  background: linear-gradient(135deg, #2980b9, var(--accent-color));
}

.action-buttons button:disabled {
  background: linear-gradient(135deg, #bdc3c7, #95a5a6);
  opacity: 0.8;
  cursor: not-allowed;
}

.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(var(--background-color), 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.script-format {
  font-family: "Courier New", Courier, monospace;
  font-size: 12pt;
  line-height: 1.5;
  padding: 1in;
  width: 8.5in;
  min-height: 11in;
  margin: 0 auto;
  background-color: var(--card-background);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  box-sizing: border-box;
  border: 1px solid var(--border-color);
  color: var(--text-color);
}

.script-format div {
  outline: none;
  margin-bottom: 1.5em;
  min-height: 1em;
  cursor: text;
  white-space: pre-wrap;
  position: relative;
  transition: background-color 0.2s;
}

.script-format div.align-left {
  text-align: left !important;
}

.script-format div.align-center {
  text-align: center !important;
}

.script-format div.align-right {
  text-align: right !important;
}

.scene-heading,
.character-name,
.parenthetical,
.dialogue,
.action,
.transition {
  margin-left: auto;
  margin-right: auto;
  max-width: 6in;
  min-width: 3in;
}

.script-format div:hover {
  background-color: var(--hover-background);
}

.script-format div:focus {
  background-color: var(--focus-background);
  outline: 1px solid var(--accent-color);
}

.script-format div:empty::before {
  content: '\200B';
}

.year-text {
  text-align: left;
  color: var(--primary-color);
  font-size: 1.2rem;
  margin-bottom: 2rem;
  font-weight: bold;
  padding-left: 2rem;
}

@media print {
  body * {
    visibility: hidden;
  }
  .script-format, .script-format * {
    visibility: visible;
  }
  .script-format {
    position: absolute;
    left: 0;
    top: 0;
  }
}

@keyframes copySuccess {
  0% { background-color: var(--accent-color); }
  50% { background-color: #2ecc71; }
  100% { background-color: var(--accent-color); }
}

.copy-animation {
  animation: copySuccess 1s ease;
}

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--accent-color);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  z-index: 1000;
}

.theme-toggle:hover {
  transform: scale(1.1);
}

.theme-toggle svg {
  width: 24px;
  height: 24px;
}