/* =========
   Base layout
   ========= */

:root {
  --bg: #f0f2f5;
  --fg: #1c1e21;
  --panel-bg: #ffffff;
  --panel-border: #e1e4e8;
  --panel-shadow: 0 4px 12px rgba(0,0,0,0.05);
  --muted: #555;
  --muted-alt: #666;
  --primary: #007bff;
  --primary-contrast: #ffffff;
  --danger: #dc3545;
  --danger-hover: #c82333;
  --success-text: #0f5132;
  --error-text: #b00020;
  --tag-bg: #e9f2ff;
  --tag-fg: #0056b3;
  --input-border: #d0d7de;
  --code-bg: #f6f8fa;
}

/* Dark theme overrides */
html[data-theme="dark"], 
body[data-theme="dark"] {
  --bg: #121212;
  --fg: #f5f5f5;
  --panel-bg: #1e1e1e;
  --panel-border: #333;
  --panel-shadow: 0 4px 16px rgba(0,0,0,0.6);
  --muted: #aaaaaa;
  --muted-alt: #999999;
  --primary: #4c8dff;
  --primary-contrast: #ffffff;
  --danger: #ff4b5c;
  --danger-hover: #e63b4a;
  --success-text: #8fd18f;
  --error-text: #ff6f6f;
  --tag-bg: #243b5a;
  --tag-fg: #9cbcff;
  --input-border: #555;
  --code-bg: #252525;
  
  background-color: var(--bg);
  color: var(--fg);
}

/* =========
   Global body + typography
   ========= */

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 40px;
}

/* NOTE (conflict: many snippets had slightly different max-width on .container):
   - request_mail, mail_created, change_password used max-width:500px
   - manage_aliases, admin_mailaccounts used 700/800/900px
   Suggestion: use one base .container and override per page with a modifier class,
   e.g. .container--wide, .container--admin */
.container {
  width: 100%;
  max-width: 700px;
}

/* Modifiers for specific pages when needed */
.container--narrow { max-width: 500px; }
.container--wide   { max-width: 900px; }

.panel {
  background: var(--panel-bg);
  padding: 30px;
  border-radius: 15px;
  box-shadow: var(--panel-shadow);
  border: 1px solid var(--panel-border);
  margin-bottom: 25px;
}

/* index.html panel needed no default padding in one version:
   .panel { /*padding: 20px 25px;* / }
   Suggestion: keep panel padding in common CSS,
   and locally override in index.html with .panel--compact if needed */
.panel--compact {
  padding: 0;
  max-width: 1000px;
  width: 100%;
}

.title {
  margin-top: 0;
  margin-bottom: 10px;
}

.subtitle {
  margin-top: 0;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 14px;
}

label {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
}

/* Inputs */

input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  font-size: 14px;
  box-sizing: border-box;
  background: var(--panel-bg);
  color: var(--fg);
}

.suffix {
  margin-left: 4px;
  color: var(--muted);
}

/* Credentials & labels (mail_created) */

.credential {
  background: var(--code-bg);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: Menlo, Consolas, monospace;
  margin-bottom: 10px;
}

.label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.hint,
.info {
  font-size: 13px;
  color: var(--muted);
  margin-top: 5px;
}

/* Buttons, links */

.btn {
  display: inline-block;
  padding: 10px 20px;
  background: var(--primary);
  color: var(--primary-contrast);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  border: none;
  cursor: pointer;
  margin-top: 10px;
}

/* NOTE (conflict: index.html used padding:12px 24px on .btn):
   Suggestion: keep base at 10x20 for most forms; use .btn--large on landing/index */
.btn--large {
  padding: 12px 24px;
}

.btn-secondary {
  background: #6c757d;
}

.btn-sm {
  display: inline-block;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}

.btn-delete {
  background: var(--danger);
  color: #fff;
}
.btn-delete:hover {
  background: var(--danger-hover);
}

.link {
  display: inline-block;
  margin-top: 15px;
  font-size: 14px;
  color: var(--primary);
  text-decoration: none;
}

/* Top bar, logout */

.top-bar {
  width: 100%;
  max-width: 1000px; /* NOTE (conflict): some used 500/700/800; this is most general */
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.top-bar h1 {
  margin: 0;
  font-size: 24px;
}

.logout-link {
  color: var(--muted-alt);
  text-decoration: none;
}

/* User info (index.html) */

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #ddd;
}

/* Cards, grid (index.html) */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  width: 100%;
  max-width: 1000px;
}

.card {
  background: var(--panel-bg);
  padding: 25px;
  border-radius: 15px;
  text-decoration: none;
  color: inherit;
  text-align: center;
  box-shadow: var(--panel-shadow);
  transition: 0.2s;
  border: 1px solid var(--panel-border);
}

.card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
}

.icon {
  font-size: 40px;
  margin-bottom: 10px;
  display: block;
}

/* Login box */

.login-box {
  text-align: center;
  background: var(--panel-bg);
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.gif {
  max-width: 250px;
  margin-bottom: 20px;
  border-radius: 10px;
}

/* Panels for mailboxes on index.html */

.panel-title {
  margin: 25px 0 10px 25px;
  font-size: 18px;
}

.panel-list {
  list-style: none;
  padding: 0;
  margin: 0 0 5px 25px;
}

.panel-list li {
  padding: 4px 0;
}

.panel-actions {
  margin: 20px 0 25px 25px;
}

.panel-actions a {
  margin-right: 10px;
  text-decoration: none;
}

/* Tags, flashes */

.tag {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  background: var(--tag-bg);
  color: var(--tag-fg);
  border-radius: 999px;
  margin-left: 8px;
}

.flash {
  margin-bottom: 10px;
  font-size: 14px;
}
.flash.error {
  color: var(--error-text);
}
.flash.success {
  color: var(--success-text);
}

/* For index.html, flash was indented; you can use a modifier if you want that: */
.flash--indented {
  margin-left: 25px;
}

/* Settings block (mail_created.html) */

.settings {
  margin-top: 15px;
}
.settings h3 {
  margin: 15px 0 8px 0;
  font-size: 15px;
}
.settings dl {
  margin: 0;
}
.settings dt {
  font-weight: 600;
  font-size: 13px;
  margin-top: 6px;
}
.settings dd {
  margin: 0;
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
}

/* Tables and wrappers (admin + aliases) */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

/* NOTE (conflict): some pages wanted min-width:700px for admin table, others full-width.
   Suggestion: default table without min-width, and use .table--wide when you need min-width. */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table--wide {
  min-width: 700px;
}

th,
td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--panel-border);
  text-align: left;
}
th {
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
}

/* Responsive tweaks */

@media (max-width: 600px) {
  body {
    /*padding: 20px;*/
  }
  .container {
    max-width: 100%;
  }
  .panel {
    /*padding: 20px;*/
  }
  .btn {
    /*width: 100%;*/
    text-align: center;
  }
  .link {
    display: block;
    text-align: center;
  }
  table {
    font-size: 12px;
  }
  th,
  td {
    padding: 6px 4px;
  }
  .top-bar h1 {
    font-size: 18px;
  }
}