/* ============================================================
   brewery.css — Shared stylesheet for Brewery ERP
   All common styles extracted from individual templates.
   ============================================================ */

/* ============================================================
   1. RESET + CSS CUSTOM PROPERTIES (VARIABLES)
   ============================================================ */
:root {
  --primary: #667eea;
  --primary-dark: #764ba2;
  --danger: #dc3545;
  --success: #28a745;
  --warning: #ffa502;
  --admin-color: #e17055;
  --admin-dark: #d63031;
}

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

/* ============================================================
   2. BODY
   ============================================================ */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  min-height: 100vh;
  padding: 20px;
}

body.admin-body {
  background: linear-gradient(135deg, var(--admin-color) 0%, var(--admin-dark) 100%);
}

/* ============================================================
   3. LAYOUT / CONTAINER
   ============================================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* ============================================================
   4. HEADER
   ============================================================ */
.header {
  background: white;
  padding: 25px 30px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  margin-bottom: 25px;
}

.header-content {
  text-align: center;
  margin-bottom: 15px;
}

.header h1 {
  color: var(--primary);
  font-size: 1.8em;
  margin-bottom: 6px;
}

.header p {
  color: #666;
  font-size: 0.95em;
}

.header.admin-header h1 {
  color: var(--admin-color);
}

.user-info {
  text-align: center;
  color: #888;
  font-size: 0.9em;
  margin-bottom: 10px;
}

.nav-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

/* ============================================================
   5. CARDS
   ============================================================ */
.card {
  background: white;
  padding: 25px;
  border-radius: 15px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.card h2 {
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ============================================================
   6. BUTTONS
   ============================================================ */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9em;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s;
  font-weight: 600;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
}

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

.btn-danger {
  background: var(--danger);
  color: white;
}

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

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #218838;
}

.btn-warning {
  background: var(--warning);
  color: #333;
}

.btn-warning:hover {
  background: #e6940f;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85em;
}

.btn-outline {
  background: white;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: #f0f4ff;
}

/* ============================================================
   7. ALERTS
   ============================================================ */
.alert {
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert-warning {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
}

.alert-info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* ============================================================
   8. FORMS
   ============================================================ */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #555;
  font-size: 0.9em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.95em;
  transition: border-color 0.3s;
  background: white;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
}

/* ============================================================
   9. TABLES
   ============================================================ */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9em;
}

th {
  background: #f8f9ff;
  color: var(--primary);
  font-weight: 600;
}

tr:hover td {
  background: #f8f9ff;
}

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

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 15px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.3s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #f0f0f0;
}

.modal-header h3 {
  color: var(--primary);
  font-size: 1.2em;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: #999;
  padding: 0 5px;
}

.modal-close:hover {
  color: #333;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 2px solid #f0f0f0;
}

/* ============================================================
   11. BADGES / STATUS
   ============================================================ */
.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: 600;
  display: inline-block;
}

.status-draft {
  background: #e9ecef;
  color: #495057;
}

.status-pending_approval {
  background: #fff3cd;
  color: #856404;
}

.status-approved {
  background: #d4edda;
  color: #155724;
}

.status-rejected {
  background: #f8d7da;
  color: #721c24;
}

.status-archived {
  background: #d6d8d9;
  color: #383d41;
}

.badge-count {
  display: inline-block;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.75em;
  line-height: 20px;
  text-align: center;
  font-weight: 700;
  margin-left: 4px;
}

/* ============================================================
   12. TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid #f0f0f0;
  flex-wrap: wrap;
}

.tab {
  padding: 10px 18px;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 0.9em;
  font-weight: 600;
  color: #888;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.3s;
  text-decoration: none;
  display: inline-block;
}

.tab:hover {
  color: var(--primary);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================================
   13. LOADING / SPINNER
   ============================================================ */
.loading {
  display: none;
  text-align: center;
  padding: 20px;
  color: #888;
}

.loading.active {
  display: block;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

/* ============================================================
   14. ANIMATIONS / KEYFRAMES
   ============================================================ */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

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

/* ============================================================
   15. TIMELINE  (used in history.html)
   ============================================================ */
.timeline {
  position: relative;
  padding-left: 30px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e0e8ff;
}

.timeline-item {
  position: relative;
  margin-bottom: 25px;
}

.timeline-dot {
  position: absolute;
  left: -26px;
  top: 5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid white;
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-dot.created  { background: #2ed573; box-shadow: 0 0 0 2px #2ed573; }
.timeline-dot.submitted { background: #ffa502; box-shadow: 0 0 0 2px #ffa502; }
.timeline-dot.approved  { background: #2ed573; box-shadow: 0 0 0 2px #2ed573; }
.timeline-dot.rejected  { background: #ff4757; box-shadow: 0 0 0 2px #ff4757; }
.timeline-dot.edited    { background: var(--primary); }

.timeline-card {
  background: #f8f9ff;
  border: 1px solid #e0e8ff;
  border-radius: 10px;
  padding: 16px 18px;
}

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

.timeline-title {
  font-weight: 700;
  color: #333;
  font-size: 0.95em;
}

.timeline-meta {
  font-size: 0.82em;
  color: #888;
}

.timeline-version {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8em;
  font-weight: 600;
}

.timeline-note {
  color: #555;
  font-size: 0.9em;
  margin-bottom: 10px;
}

.snapshot-toggle {
  font-size: 0.82em;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  display: inline-block;
  margin-top: 5px;
}

.snapshot-data {
  display: none;
  margin-top: 10px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 12px;
  font-size: 0.82em;
  font-family: monospace;
  overflow-x: auto;
  white-space: pre-wrap;
  color: #333;
  max-height: 200px;
  overflow-y: auto;
}

.snapshot-data.visible {
  display: block;
}

.change-type-badge {
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.78em;
  font-weight: 600;
}

.ct-created       { background: #d4edda; color: #155724; }
.ct-edited        { background: #d1ecf1; color: #0c5460; }
.ct-submitted     { background: #fff3cd; color: #856404; }
.ct-approved      { background: #d4edda; color: #155724; }
.ct-direct_approved { background: #d4edda; color: #155724; }
.ct-rejected      { background: #f8d7da; color: #721c24; }

.archived-badge {
  background: #d6d8d9;
  color: #383d41;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.75em;
  font-weight: 600;
  margin-left: 6px;
}

.timeline-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.btn-sm.btn-archive {
  background: #6c757d;
  color: white;
}

.btn-sm.btn-archive:hover {
  background: #5a6268;
}

.btn-sm.btn-unarchive {
  background: #ffc107;
  color: #333;
}

.btn-sm.btn-unarchive:hover {
  background: #e0a800;
}

/* ============================================================
   16. VERSION NAVIGATION  (used in version_detail.html)
   ============================================================ */
.nav-versions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.nav-versions a {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 600;
  text-decoration: none;
  background: #e9ecef;
  color: #495057;
  border: 2px solid transparent;
}

.nav-versions a.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.nav-versions a:hover:not(.active) {
  background: #dde;
}

/* ============================================================
   17. EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 50px;
  color: #999;
}

/* ============================================================
   18. ADMIN-SPECIFIC  (admin pages — orange-red scheme)
   ============================================================ */
.admin-header h1 {
  color: var(--admin-color);
}

.btn-admin {
  background: linear-gradient(135deg, var(--admin-color) 0%, var(--admin-dark) 100%);
  color: white;
}

.btn-admin:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(225, 112, 85, 0.4);
}
