/* ========================================
   MAILATLAS GLOBAL DESIGN
======================================== */

:root {
  --bg-main: #0b1120;
  --bg-panel: #0f172a;
  --bg-panel-light: #111827;
  --border: #1e293b;
  --border-light: #334155;
  --text-main: #ffffff;
  --text-muted: #94a3b8;
  --text-soft: #cbd5e1;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --red: #ef4444;
  --red-dark: #dc2626;
  --green: #22c55e;
  --yellow: #facc15;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --sidebar-width: 245px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at top, #111c33 0%, var(--bg-main) 45%);
  color: var(--text-main);
  min-height: 100vh;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* ========================================
   SIDEBAR
======================================== */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  background: linear-gradient(180deg, #111827 0%, #0b1120 100%);
  padding: 24px 18px;
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 20;
}

.sidebar h2 {
  margin-bottom: 30px;
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.sidebar-section-title {
  margin: 18px 0 8px;
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar a {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 13px 15px;
  margin-bottom: 9px;
  color: var(--text-soft);
  text-decoration: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  border: 1px solid transparent;
  line-height: 1.2;
  outline: none;
  transform: none;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.sidebar a:hover {
  background: #1e293b;
  color: var(--text-main);
  border-color: #263449;
}

.sidebar a.active {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: var(--text-main);
  border-color: rgba(37, 99, 235, 0.45);
}

.sidebar a.active:hover {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
}

.user-badge {
  margin-top: -18px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.10);
  border: 1px solid rgba(37, 99, 235, 0.22);
  color: #bfdbfe;
  font-size: 12px;
  font-weight: 800;
  word-break: break-word;
}

.logout-btn {
  width: 100%;
  margin-top: 16px;
  background: linear-gradient(135deg, #334155, #1e293b);
}

.role-worker .owner-only {
  display: none !important;
}

/* ========================================
   MAIN CONTENT
======================================== */

.main-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  padding: 30px;
}

.container {
  width: 100%;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

h1 {
  margin-bottom: 24px;
  font-size: 34px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.8px;
}

h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 18px;
}

/* ========================================
   FORMS / ACTION BARS
======================================== */

.top-bar,
.bulk-actions,
.settings-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  align-items: center;
}

input,
select,
textarea {
  background: var(--bg-panel-light);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: #64748b;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.top-bar input {
  min-width: 300px;
  flex: 1;
}

select {
  min-width: 180px;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 100px;
}

/* ========================================
   BUTTONS
======================================== */

button {
  padding: 11px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: white;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition:
    opacity 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}

button:hover {
  opacity: 0.96;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.delete-btn {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
}

.delete-btn:hover {
  box-shadow: 0 8px 18px rgba(239, 68, 68, 0.24);
}

.replace-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* ========================================
   TABLES
======================================== */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-panel-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

thead {
  background: #1e293b;
}

th {
  color: #e2e8f0;
  padding: 14px;
  text-align: left;
  font-size: 13px;
  font-weight: 800;
  border-bottom: 1px solid var(--border-light);
}

td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.035);
}

tbody tr:last-child td {
  border-bottom: none;
}

td button {
  margin-right: 6px;
  margin-bottom: 4px;
}

/* ========================================
   STATUS COLORS
======================================== */

.green {
  color: var(--green);
  font-weight: 800;
}

.red {
  color: var(--red);
  font-weight: 800;
}

.yellow {
  color: var(--yellow);
  font-weight: 800;
}

/* ========================================
   CUSTOM FILE UPLOAD
======================================== */

.custom-file-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border-radius: 10px;
  background: #111827;
  border: 1px solid #334155;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
  white-space: nowrap;
}

.custom-file-upload:hover {
  border-color: #2563eb;
  background: #1e293b;
}

.custom-file-upload input {
  display: none;
}

/* ========================================
   EMAIL HOST UPLOAD ROW
======================================== */

.email-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  flex-wrap: nowrap;
}

.email-upload-row input[type="text"] {
  flex: 1;
  height: 44px;
}

.email-upload-row .custom-file-upload {
  height: 44px;
  padding: 0 18px;
}

.email-upload-row .selected-file-name {
  height: 44px;
  display: flex;
  align-items: center;
  min-width: 170px;
  color: var(--text-muted);
  font-size: 13px;
}

.email-upload-row button {
  height: 44px;
  min-width: 170px;
}

/* ========================================
   SETTINGS PAGE
======================================== */

.settings-card {
  background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 22px;
}

.settings-card h2 {
  margin-bottom: 18px;
}

.settings-note {
  margin-top: 18px;
  margin-bottom: 18px;
  padding: 18px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 14px;
  color: #cbd5e1;
  line-height: 1.7;
  font-size: 14px;
}

.settings-note strong {
  color: #ffffff;
  font-size: 15px;
}

.feature-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.feature-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 4px 12px;
  align-items: start;
  padding: 16px;
  border-radius: 14px;
  background: #0f172a;
  border: 1px solid #1e293b;
}

.feature-item input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.feature-item strong {
  display: block;
  font-size: 14px;
  color: #ffffff;
}

.feature-item span {
  display: block;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.5;
}

.api-key-value {
  font-family: monospace;
  color: #93c5fd;
  font-size: 13px;
  word-break: break-all;
}

.used-by-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.used-by-item {
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.14);
  color: #bfdbfe;
  font-size: 12px;
  font-weight: 700;
}

/* ========================================
   GUIDE
======================================== */

.guide-box {
  margin-bottom: 22px;
  padding: 18px;
  border-radius: 14px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.22);
}

.guide-box h3 {
  margin-bottom: 10px;
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
}

.guide-box p {
  color: #cbd5e1;
  line-height: 1.7;
  margin-bottom: 10px;
  font-size: 14px;
}

.guide-box ul {
  padding-left: 18px;
}

.guide-box li {
  color: #94a3b8;
  margin-bottom: 6px;
  line-height: 1.5;
  font-size: 14px;
}

/* ========================================
   LOGIN
======================================== */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 430px;
  background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.login-card h1 {
  margin-bottom: 8px;
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.login-card input {
  width: 100%;
  margin-bottom: 12px;
}

.login-card button {
  width: 100%;
  margin-top: 6px;
}

.login-help {
  margin-top: 18px;
  padding: 14px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 14px;
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.7;
}

.login-message {
  margin-top: 12px;
  font-size: 13px;
  color: var(--red);
  font-weight: 800;
}

/* ========================================
   TASK BOARD
======================================== */

.task-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.task-columns {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 16px;
  align-items: start;
}

.task-column {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  min-height: 240px;
}

.task-column h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.task-card {
  background: #111827;
  border: 1px solid #263449;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.task-card-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.task-card p {
  color: #cbd5e1;
  line-height: 1.55;
  font-size: 13px;
  margin-bottom: 12px;
}

.task-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #94a3b8;
  font-size: 12px;
  margin-bottom: 12px;
}

.task-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.priority {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.priority-low {
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
}

.priority-medium {
  background: rgba(37, 99, 235, 0.14);
  color: #93c5fd;
}

.priority-high {
  background: rgba(250, 204, 21, 0.14);
  color: #fde68a;
}

.priority-urgent {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

.empty-task {
  color: #64748b;
  font-size: 13px;
  padding: 12px;
  border: 1px dashed #334155;
  border-radius: 12px;
}

/* ========================================
   RESPONSIVE
======================================== */

@media (max-width: 1200px) {
  .task-columns {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .task-form-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 900px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    position: relative;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar h2 {
    margin-bottom: 0;
    margin-right: 10px;
    white-space: nowrap;
    font-size: 20px;
  }

  .sidebar-section-title {
    display: none;
  }

  .sidebar a {
    white-space: nowrap;
    margin-bottom: 0;
    padding: 10px 12px;
    min-height: 42px;
  }

  .user-badge {
    display: none;
  }

  .logout-btn {
    width: auto;
    margin-top: 0;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 18px;
  }

  .container {
    padding: 20px;
  }

  .feature-list {
    grid-template-columns: 1fr;
  }

  .email-upload-row {
    flex-direction: column;
    align-items: stretch;
  }

  .email-upload-row input,
  .email-upload-row button,
  .email-upload-row .custom-file-upload,
  .email-upload-row .selected-file-name {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .task-columns,
  .task-form-grid {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 520px) {
  .main-content {
    padding: 12px;
  }

  .container {
    padding: 16px;
    border-radius: 14px;
  }

  h1 {
    font-size: 24px;
  }

  td,
  th {
    padding: 11px;
  }
}
