/* ===== CMS THEME VARIABLES ===== */
:root {
  --primary: #1EB6DE;
  --primary-dark: #1892B2;
  --light-bg: #F8FCFF;
  --border: #E1E5F1;
  --text: #1E293B;
  --text-light: #475569;
  --card-bg: #FFFFFF;
  --toast-bg: #2C3E50;
  --switch-bg: #CBD5E1;
  --switch-active: #1BA4C8;
  --danger: #E53E3E;
  --success: #2C7A4D;
  --warning: #ED8936;
  --info: #4299E1;
  --disabled-bg: #E2E8F0;
  --disabled-text: #94A3B8;
  
  /* Strength Colors - HEX ONLY */
  --strength-weak: #EF4444;
  --strength-fair: #F97316;
  --strength-good: #EAB308;
  --strength-strong: #22C55E;
  --strength-very-strong: #16A34A;
  
  /* Password Character Colors - HEX ONLY */
  --pw-num-color: #2563EB;
  --pw-sym-color: #D946EF;
}
[data-theme="dark"] {
  --primary: #1EB6DE;
  --primary-dark: #1892B2;
  --light-bg: #292B32;
  --border: #4A4A5A;
  --text: #F1F5F9;
  --text-light: #CBD5E1;
  --card-bg: #1E1F28;
  --toast-bg: #111827;
  --switch-bg: #4B5563;
  --switch-active: #1BA4C8;
  --danger: #F56565;
  --success: #48BB78;
  --warning: #F6AD55;
  --info: #63B3ED;
  --disabled-bg: #374151;
  --disabled-text: #64748B;
  
  --strength-weak: #DC2626;
  --strength-fair: #C2410C;
  --strength-good: #CA8A04;
  --strength-strong: #16A34A;
  --strength-very-strong: #15803D;
  
  --pw-num-color: #60A5FA;
  --pw-sym-color: #E879F9;
}

/* ===== BASE RESET ===== */
*, *::before, *::after { box-sizing: border-box; }

/* ===== GLOBAL UTILITIES ===== */
.fa-sm { font-size: 0.875em; vertical-align: -0.1em; }
button i { display: inline-flex; align-items: center; justify-content: center; width: 1em; }
.panel-hidden { display: none !important; }
code { background: var(--light-bg); padding: 2px 6px; border-radius: 3px; font-size: 12px; color: var(--text); border: 1px solid var(--border); }
input[type="file"] { display: none; }

/* ===== BUTTONS (STANDARD SIZE) ===== */
button {
  font-family: inherit; font-size: 13px; font-weight: 600; border-radius: 3px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; background: var(--light-bg); color: var(--text); border: 1px solid var(--border);
  min-height: 38px; padding: 0 14px; white-space: nowrap; text-shadow: none;
  box-sizing: border-box; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
}
button:hover { border-color: var(--primary); background: rgba(30, 182, 222, 0.08); }
button:active { transform: scale(0.98); background: rgba(30, 182, 222, 0.15); }
button:focus { outline: none; }
button:focus-visible { box-shadow: 0 0 0 2px rgba(30, 182, 222, 0.4); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
button.primary { background: var(--primary); border-color: var(--primary); color: white; }
button.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
button.secondary { background: var(--light-bg); border: 1px solid var(--border); }
button.secondary:hover { border-color: var(--primary); background: rgba(30, 182, 222, 0.1); color: var(--text); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== CUSTOM SELECT DROPDOWN ===== */
.custom-select {
  padding: 8px 28px 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  min-height: 34px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
}
.custom-select:focus { outline: none; border-color: var(--primary); }
.custom-select:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== CONTAINER & LAYOUT ===== */
.container-custom {
  width: 100%; max-width: none; margin: 0 auto; border-radius: 0;
  background: var(--card-bg); box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.1); 
  transition: background 0.2s; overflow: hidden; padding: 0;
}
.tool-header { padding: 12px 16px 0 16px; border-bottom: 1px solid var(--border); }
.tool-header-content { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.tool-title { margin: 0; color: var(--primary); font-size: 1.4rem; display: flex; align-items: center; gap: 10px; }
.tool-subtitle { margin: 4px 0 0 0; color: var(--text-light); font-size: 0.9rem; }

/* ===== STICKY TOOLBAR ===== */
.sticky-toolbar { position: sticky; top: 0; z-index: 15; background: var(--light-bg); border-bottom: 1px solid var(--border); }

/* ===== OPTIONS TOOLBAR ===== */
.options-toolbar { display: flex; gap: 12px; padding: 12px 16px; background: var(--light-bg); flex-wrap: wrap; align-items: center; width: 100%; }
.options-toolbar .switch-item { display: flex; align-items: center; gap: 5px; }
.switch-item { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid rgba(0,0,0,0.05); flex-wrap: nowrap; }
.switch-item:last-child { border-bottom: none; }
.switch-item.disabled { opacity: 0.5; pointer-events: none; }
.switch-label { display: flex; align-items: center; gap: 4px; font-size: 0.85rem; font-weight: 500; cursor: pointer; color: var(--text); flex: 0 0 auto; }
.switch-label i { color: var(--primary); flex-shrink: 0; }
.label-abc { font-family: 'Consolas', monospace; font-weight: 700; font-size: 13px; color: var(--primary); letter-spacing: -0.5px; }
.switch { position: relative; display: inline-block; width: 46px; height: 24px; overflow: hidden; border-radius: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--switch-bg); transition: 0.25s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 22px; width: 22px; left: 1px; bottom: 1px; background-color: white; transition: 0.25s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
input:checked + .slider { background-color: var(--switch-active); }
input:checked + .slider:before { transform: translateX(22px); }
input:disabled + .slider { background-color: var(--disabled-bg) !important; cursor: not-allowed; }
input:disabled + .slider:before { background-color: var(--disabled-text) !important; }

/* ===== FILTER PANELS & INPUTS ===== */
.filter-options { background: var(--light-bg); border-bottom: 1px solid var(--border); padding: 8px 16px; transition: all 0.2s ease; }
.filter-options.open { display: block !important; }
.custom-input-group { display: flex; gap: 8px; margin-top: 0; flex-wrap: wrap; width: 100%; }
.custom-input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--card-bg); color: var(--text); font-size: 13px; min-width: 0; box-sizing: border-box; text-align: center; margin-bottom: 0 !important; }
.custom-input:focus { outline: none; border-color: var(--primary); }

/* ===== EDITOR SECTION ===== */
.editor-section { padding: 10px 16px; background: var(--light-bg); }
.editor-header-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.action-right { margin-left: auto; white-space: nowrap; }

/* ===== SLIDER CONTROLS & PRESETS (DESKTOP) ===== */
.length-row { display: flex; align-items: center; gap: 10px; flex: 1; flex-wrap: wrap; }
.len-text { font-size: 13px; color: var(--text-light); font-weight: 600; white-space: nowrap; }
.len-text strong { color: var(--primary); font-size: 19px; margin-left: 2px; }

/* Standard Button Size for +/- and Presets */
.len-btn { min-width: 42px; padding: 0; }
.preset-btns { display: flex; gap: 6px; }
.preset-btn { min-width: 44px; font-weight: 700; }
.preset-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Strength Pill Indicator */
.strength-pill {
  font-size: 12px; font-weight: 700; padding: 6px 14px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.5px; color: white;
  background: var(--strength-strong); flex-shrink: 0;
}
.strength-pill.weak { background: var(--strength-weak); }
.strength-pill.fair { background: var(--strength-fair); }
.strength-pill.good { background: var(--strength-good); color: #1E293B; }
.strength-pill.strong { background: var(--strength-strong); }
.strength-pill.very-strong { background: var(--strength-very-strong); }

/* ===== OUTPUT CONTAINER & ROWS ===== */
.output-container { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px 0; }
.password-row { display: flex; align-items: center; gap: 10px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; transition: border-color 0.2s; flex-wrap: wrap; }
.password-row:focus-within { border-color: var(--primary); }

.password-field { 
  flex: 1; color: var(--text); font-family: 'Consolas', 'Monaco', monospace; 
  font-size: 22px; font-weight: 600; padding: 6px 8px; letter-spacing: 0.3px; 
  min-width: 200px; box-sizing: border-box; user-select: text; word-break: break-all;
  line-height: 1.5; background: transparent; border: none;
}
/* Color Classes */
.pw-num { color: var(--pw-num-color); font-weight: 700; }
.pw-sym { color: var(--pw-sym-color); font-weight: 700; }
.no-color .pw-num, .no-color .pw-sym { color: inherit; font-weight: inherit; }

/* Strength & Actions */
.strength-badge { font-size: 14px; font-weight: 700; padding: 5px 8px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; flex-shrink: 0; color: white; min-width: 75px; text-align: center; }
.strength-badge.weak { background: var(--strength-weak); }
.strength-badge.fair { background: var(--strength-fair); }
.strength-badge.good { background: var(--strength-good); color: #1E293B; }
.strength-badge.strong { background: var(--strength-strong); }
.strength-badge.very-strong { background: var(--strength-very-strong); }

.password-actions { display: flex; gap: 4px; flex-shrink: 0; }
.password-actions button { min-width: 36px; padding: 0 10px; min-height: 34px; border-radius: 4px; font-size: 12px; }
.password-actions .copy-pw, .password-actions .refresh-pw { background: var(--light-bg); border: 1px solid var(--border); }
.password-actions .copy-pw:hover, .password-actions .refresh-pw:hover { border-color: var(--primary); background: rgba(30, 182, 222, 0.1); color: var(--text); }

/* ===== HELPER TEXT & STATS ===== */
.helper-text { font-size: 12px; color: var(--text-light); margin: 8px 0 12px 0; padding: 8px 12px; background: rgba(30, 182, 222, 0.08); border-left: 3px solid var(--primary); border-radius: 0 4px 4px 0; }
.stats-inline { display: flex; gap: 16px; font-size: 12px; color: var(--text-light); flex-wrap: wrap; align-items: center; }

/* ===== TOAST ===== */
#toastContainer { position: fixed; bottom: 24px; right: 24px; z-index: 1000; max-width: calc(100% - 48px); }
.toast { background: var(--toast-bg); color: white; padding: 12px 20px; border-radius: 5px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 10px; font-size: 14px; margin-top: 8px; animation: slideUp 0.3s ease, fadeOut 0.3s ease 2.7s forwards; max-width: 350px; border-left: 4px solid var(--primary); box-sizing: border-box; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--info); }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(10px); } }

/* ===== RESPONSIVE: MOBILE LAYOUT ===== */

/* Tablet: Action button below controls */
@media (max-width: 992px) {
  .editor-header-row { justify-content: flex-start; flex-direction: column; align-items: stretch; }
  .action-right { width: 100%; justify-content: center; margin-left: 0; margin-top: 10px; }
}

/* Mobile: 3-row stacked layout */
@media (max-width: 768px) {
  .tool-header { padding: 12px 12px 0 12px; }
  .tool-header-content { flex-direction: column; align-items: flex-start; gap: 8px; }
  .btn-group { width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 6px; }
  
  .options-toolbar { padding: 10px 12px; gap: 2px; width: 100%; }
  .options-toolbar .switch-item { flex: 0 0 100%; width: 100%; margin-bottom: 6px; }
  #advancedOptionsToggle { width: 100%; margin-left: 0 !important; margin-top: 4px; justify-content: center; }
  
  .editor-section { padding: 10px 12px; }
  
  .length-row { 
    width: 100%; 
    flex-direction: column; 
    align-items: center;
    gap: 12px;
  }
  
  /* Row 1: Label */
  .len-text { 
    font-size: 14px; 
    width: 100%;
    text-align: center;
    padding: 2px 0;
  }
  .len-text strong { font-size: 20px; }
  
  /* Row 2: Strength Indicator */
  .slider-control-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
  }
  
  /* Row 3: Presets */
  .preset-btns { 
    display: flex; 
    gap: 8px; 
    justify-content: center; 
    width: 100%;
    flex-wrap: wrap;
  }
  .preset-btn { 
    min-width: 48px; 
    min-height: 38px; 
    font-weight: 700; 
    font-size: 12px;
  }
  .preset-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
  
  /* Password Row Layout */
  .password-row { 
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  
  .password-field { 
    min-width: 140px;
    font-size: 16px;
    flex: 1 1 100%;
    order: 1;
  }
  
  .strength-badge { 
    order: 2; 
    align-self: center; 
    margin: 0;
    min-width: 70px;
    font-size: 9px;
    padding: 2px 6px;
  }
  
  /* FIX: Align password actions to the right */
  .password-actions { 
    order: 3; 
    flex: 1;
    justify-content: flex-end;
    margin: 0;
    gap: 4px;
  }
  .password-actions button { 
    min-width: 34px; 
    min-height: 32px; 
    padding: 0 8px; 
    font-size: 11px;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .tool-title { font-size: 1.2rem; }
  .tool-subtitle { font-size: 0.85rem; }
  .btn-group { justify-content: center; }
  .btn-group button { flex: 1 0 auto; min-width: 0; justify-content: center; }
  .stats-inline { flex-direction: column; align-items: flex-start; gap: 4px; font-size: 11px; }
  
  .password-field { font-size: 15px; padding: 5px 6px; min-height: 36px; }
  .strength-badge { font-size: 8px; padding: 2px 5px; min-width: 65px; }
  
  #toastContainer { right: 12px; left: 12px; max-width: calc(100% - 24px); }
  .toast { max-width: 100%; }
  
  .custom-select { font-size: 12px; padding: 7px 24px 7px 8px; background-size: 14px; background-position: right 6px center; }
}