/*
Copyright (C) 2025 dfkdream

This file is part of bakers-percentage.
bakers-percentage is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
bakers-percentage is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with bakers-percentage. If not, see <https://www.gnu.org/licenses/>. 
*/

:root {
  --primary-color: #d35400;
  --primary-light: #e67e22;
  --bg-color: #fdfbf7;
  --border-color: #ddd;
  --text-color: #333;
  --row-hover: #fff3e0;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, system-ui,
    Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 1000px;
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--primary-color);
}

.control-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  background: #eee;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  align-items: end; /* 체크박스 라인 맞춤 */
}

.control-group {
  display: flex;
  flex-direction: column;
}

.control-group label {
  font-size: 0.85rem;
  margin-bottom: 5px;
  font-weight: bold;
  color: #666;
}

.control-group input[type="number"],
.control-group input[type="text"] {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  text-align: right;
}

.control-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(211, 84, 0, 0.2);
}

/* Checkbox switch style for Scale Mode */
.toggle-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: bold;
  color: var(--primary-color);
  font-size: 0.9rem;
  background: #fff;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #ddd;
  height: 42px; /* input height와 맞춤 */
}
.toggle-label input {
  margin-right: 8px;
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
}

/* Table Styles */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

th,
td {
  padding: 12px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #555;
  position: sticky;
  top: 0;
}

tr:last-child td {
  border-bottom: none;
}
tr:hover {
  background-color: var(--row-hover);
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 1rem;
  text-align: center;
  border-radius: 4px;
}

td.align-left input {
  text-align: left;
}
td.align-right input {
  text-align: right;
}

input:focus {
  background: white;
  border-color: var(--primary-color);
  outline: none;
}

input.percent-input {
  color: var(--primary-color);
  font-weight: bold;
}
input.weight-input {
  font-weight: 500;
}

.is-flour-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.btn-icon:hover {
  opacity: 1;
  color: red;
}

/* Footer Actions */
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.btn-secondary {
  background-color: #fff;
  border: 1px solid #ccc;
  color: #555;
}
.btn-secondary:hover {
  background-color: #f0f0f0;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
}
.btn-outline:hover {
  background: #fff3e0;
}

/* Toast Message */
#toast {
  visibility: hidden;
  min-width: 250px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 4px;
  padding: 16px;
  position: fixed;
  z-index: 1;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s;
}
#toast.show {
  visibility: visible;
  opacity: 1;
}

/* Footer */
footer {
  text-align: center;
  padding-top: 20px;
}

/* Open Source License */
pre {
  overflow-y: scroll;
}

@media (max-width: 600px) {
  .container {
    padding: 15px;
  }
  .control-panel {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 1.2rem;
  }
}
