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

:root {
  --color-primary-pink: #ffb3b3;
  --color-primary-green: #b3e6b3;
  --color-blue: #b3d9ff;
  --color-yellow: #fff4b3;
  --color-orange: #ffd9b3;
  --color-purple: #e6b3ff;
  --color-red: #ffb3c1;
  --color-teal: #b3f0f0;

  --color-border: #e0e0e0;
  --color-background: #ffffff;
  --color-text: #333333;

  --cell-height: 25px;
  --time-column-width: 60px;
  --gap-size: 1px;
  --font-size-base: 12px;
}

html,
body {
  height: 100%;
  background-color: var(--color-background);
  color: var(--color-text);
}

body {
  font-family: "moonblossom", sans-serif;
  font-weight: 400;
  font-style: normal;
  font-size: 12px;
  line-height: 1.5;
}

.app-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 30px;
  background-color: var(--color-background);
  position: relative;
}

.share-btn {
  position: absolute;
  right: 120px;
}

.login-btn {
  position: absolute;
  right: 30px;
}

@media (min-width: 1024px) {
  .app-header {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding-left: 0;
    padding-right: 0;
  }

  .share-btn {
    right: 90px;
  }

  .login-btn {
    right: 0;
  }
}

/* Custom Schedule Dropdown */
.schedule-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.schedule-dropdown-btn {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: "moonblossom", sans-serif;
  font-size: 14px;
  background-color: var(--color-background);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.schedule-dropdown-btn:hover {
  background-color: #fafafa;
  border-color: #ccc;
}

.schedule-dropdown-btn:active {
  background-color: #f5f5f5;
}

.schedule-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  min-width: 200px;
  display: none;
  margin-top: 4px;
}

.schedule-dropdown-menu.open {
  display: block;
}

.schedule-menu-list {
  max-height: 300px;
  overflow-y: auto;
}

.schedule-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background-color: transparent;
  font-family: "moonblossom", sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.15s;
  text-align: left;
}

.schedule-menu-item:hover {
  background-color: #f5f5f5;
}

.schedule-menu-item.active {
  background-color: #f0f0f0;
  font-weight: 600;
}

.schedule-item-name {
  flex: 1;
  color: var(--color-text);
}

.schedule-item-icons {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.schedule-item-icon-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background-color: transparent;
  font-family: "moonblossom", sans-serif;
  font-size: 12px;
  color: #ccc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.schedule-item-icon-btn:hover {
  color: #999;
}

.schedule-menu-divider {
  height: 1px;
  background-color: var(--color-border);
  margin: 4px 0;
}

.schedule-menu-new {
  padding: 0;
}

.schedule-new-btn {
  padding: 8px 12px;
  color: #999;
  font-weight: 400;
}

.schedule-new-btn:hover {
  background-color: #fafafa;
}

.schedule-new-btn .schedule-item-icon {
  font-size: 14px;
  color: #999;
}

.share-btn {
  padding: 10px;
  border: none;
  border-radius: 4px;
  background-color: transparent;
  cursor: pointer;
  transition: background-color 0.2s;
}

.share-btn .material-icons {
  font-size: 20px;
  color: #999;
  transition: color 0.2s;
}

.share-btn:hover {
  background-color: #f5f5f5;
}

.share-btn:hover .material-icons {
  color: #666;
}

.share-btn:active {
  background-color: #f0f0f0;
}

.login-btn {
  padding: 10px;
  border: none;
  border-radius: 4px;
  background-color: transparent;
  cursor: pointer;
  transition: background-color 0.2s;
}

.login-btn .material-icons {
  font-size: 20px;
  color: #999;
  transition: color 0.2s;
}

.login-btn:hover {
  background-color: #f5f5f5;
}

.login-btn:hover .material-icons {
  color: #666;
}

.login-btn:active {
  background-color: #f0f0f0;
}

.app-container {
  padding: 20px 30px;
  padding-bottom: 40px;
  min-height: calc(100% - 80px);
  overflow: auto;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
}

.schedule-grid {
  display: grid;
  grid-template-columns: var(--time-column-width) repeat(7, 1fr);
  grid-template-rows: auto repeat(34, var(--cell-height));
  gap: var(--gap-size);
  background-color: var(--color-border);
  padding: var(--gap-size);
  border-radius: 12px;
  overflow: visible;
  border: 2px solid var(--color-border);
  min-width: fit-content;
  max-width: 1200px;
  width: 100%;
  position: relative;
}

.grid-time-header {
  background-color: var(--color-background);
  border-right: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  grid-column: 1;
  grid-row: 1;
}

.grid-day-header {
  background-color: var(--color-background);
  border-right: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 600;
  min-height: 50px;
  border-bottom: 1px solid var(--color-border);
  grid-row: 1;
}

.grid-day-header:last-child {
  border-right: none;
}

.grid-time-label {
  background-color: var(--color-background);
  border-right: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  height: var(--cell-height);
  min-width: var(--time-column-width);
  grid-column: 1;
}

.grid-cell {
  background-color: var(--color-background);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  height: var(--cell-height);
  cursor: pointer;
  transition: background-color 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-cell::before {
  content: "+";
  font-size: 24px;
  color: #d0d0d0;
  font-weight: 300;
  user-select: none;
  pointer-events: none;
}

.grid-cell:hover {
  background-color: #fafafa;
}

.grid-cell:hover::before {
  color: #b0b0b0;
}

.grid-cell.paste-mode {
  background-color: #e8f5e9;
  cursor: copy;
}

.grid-cell.paste-mode:hover {
  background-color: #c8e6c9;
}

.grid-cell:last-child {
  border-right: none;
}

.schedule-block {
  background-color: var(--color-primary-pink);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 8px;
  cursor: move;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  user-select: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: opacity 0.2s;
  margin: 1px;
  position: relative;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--cell-height) - 1px),
    rgba(0, 0, 0, 0.041) calc(var(--cell-height) - 1px),
    rgba(0, 0, 0, 0.15) var(--cell-height)
  );
  background-size: 6px var(--cell-height);
}

/* Smooth transitions when blocks are placed back on grid */
.schedule-block.settling {
  transition: left 0.3s ease-out, top 0.3s ease-out, position 0.3s ease-out;
}

.schedule-block:hover {
  opacity: 0.95;
}

.schedule-block.dragging {
  opacity: 0.7;
  z-index: 1000;
}

.schedule-block.resizing {
  opacity: 0.7;
}

/* Smooth transitions for resize operations */
.schedule-block.resize-settling {
  transition: grid-row-start 0.3s ease-out, grid-row-end 0.3s ease-out,
    height 0.3s ease-out;
}

.block-name {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text);
  word-break: break-word;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  position: relative;
  z-index: 15;
}

.block-name.editing {
  background-color: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 4px;
}

.block-controls {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 10;
}

.schedule-block:hover .block-controls {
  opacity: 1;
  pointer-events: auto;
}

.block-btn {
  width: 17px;
  height: 17px;
  border: none;
  background-color: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #999;
  transition: color 0.2s;
  padding: 0;
  position: absolute;
  pointer-events: auto;
}

.block-btn:hover {
  color: #666;
}

/* Allow resize handles to be clicked even when controls are visible */
.resize-handle-top,
.resize-handle {
  pointer-events: auto;
  z-index: 20;
}

/* Delete button - top right */
.delete-btn {
  top: 12px;
  right: 4px;
}

/* Copy button - top left */
.copy-btn {
  top: 12px;
  left: 4px;
}

.resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 0 0 8px 8px;
  z-index: 20;
  pointer-events: auto;
}

.resize-handle-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 8px 8px 0 0;
  z-index: 20;
  pointer-events: auto;
}

/* Input field for block name editing */
.block-name-input {
  box-sizing: border-box;
  max-width: 90%;
  min-width: 0;
}

/* Read-Only View Styles */
body.read-only-view .schedule-dropdown-wrapper {
  display: none;
}

body.read-only-view #loginBtn {
  display: none;
}

body.read-only-view #shareBtn {
  display: none;
}

body.read-only-view .delete-btn {
  display: none;
}

body.read-only-view .copy-btn {
  display: none;
}

body.read-only-view .resize-handle {
  pointer-events: none;
  opacity: 0;
}

body.read-only-view .resize-handle-top {
  pointer-events: none;
  opacity: 0;
}

body.read-only-view .grid-cell {
  cursor: default;
}

/* Update header title for read-only view */
body.read-only-view .app-header {
  justify-content: center;
}

body.read-only-view #headerTitle {
  display: inline-block;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}

/* Sign-in Reminder Popup */
.reminder-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease-out;
  pointer-events: auto;
}

.reminder-popup-content {
  background: white;
  padding: 24px 32px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  max-width: 400px;
  font-family: "moonblossom", sans-serif;
  animation: slideUp 0.3s ease-out;
  position: relative;
  z-index: 10000;
  pointer-events: auto;
}

.reminder-popup-message {
  font-size: 16px;
  color: #333;
  margin-bottom: 20px;
  line-height: 1.6;
  margin: 0 0 20px 0;
}

.reminder-popup-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.reminder-btn-dismiss {
  padding: 8px 16px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-family: "moonblossom", sans-serif;
  font-size: 14px;
  color: #333;
  transition: background-color 0.2s, border-color 0.2s;
}

.reminder-btn-dismiss:hover {
  background: #efefef;
  border-color: #bbb;
}

.reminder-btn-login {
  padding: 8px 20px;
  background: #333;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: "moonblossom", sans-serif;
  font-size: 14px;
  transition: background-color 0.2s;
}

.reminder-btn-login:hover {
  background: #555;
}

.reminder-popup.fade-out {
  animation: fadeOut 0.2s ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
