/* ═══════════════════════════════════════════════════════════════
   AK International – Shared Stylesheet
   India ERP  |  v3.0 – Compact & Refined
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-primary:    #f0f2f5;
  --bg-secondary:  #f7f8fa;
  --card-bg:       #ffffff;
  --modal-bg:      #ffffff;

  /* Text */
  --text-primary:  #1e293b;
  --text-secondary:#64748b;

  /* Navbar */
  --navbar-bg:     #A4EBF3;
  --navbar-text:   #1e293b;

  /* Borders & accents */
  --border-color:  #e2e8f0;
  --accent:        #6366f1;
  --accent2:       #8b5cf6;
  --green:         #10b981;
  --red:           #ef4444;
  --orange:        #f59e0b;
  --blue:          #3b82f6;

  /* Shadows */
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 2px 8px rgba(0,0,0,.07);
  --shadow-lg:     0 10px 30px rgba(0,0,0,.12);

  /* Radii */
  --radius:        8px;
  --radius-lg:     14px;

  /* Gradient */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body.dark-mode {
  --bg-primary:    #121826;
  --bg-secondary:  #1a2035;
  --card-bg:       #1e293b;
  --modal-bg:      #1e293b;
  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --navbar-bg:     #1e293b;
  --navbar-text:   #f1f5f9;
  --border-color:  #334155;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.2);
  --shadow-md:     0 2px 8px rgba(0,0,0,.3);
  --shadow-lg:     0 10px 30px rgba(0,0,0,.5);
}

/* ── Aliases (backward compat with some templates) ─────────── */
:root {
  --bg:   var(--bg-primary);
  --bg2:  var(--card-bg);
  --bg3:  var(--bg-secondary);
  --text: var(--text-primary);
  --text2:var(--text-secondary);
  --border:var(--border-color);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html { font-size: 14px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background .25s, color .25s;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ── Topbar / Navbar ────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0;
  background: var(--navbar-bg);
  backdrop-filter: blur(12px);
  padding: 6px 20px;
  display: flex; justify-content: space-between; align-items: center;
  z-index: 1000;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border-bottom: 2px solid #00e5ff;
  box-shadow: 0 2px 12px rgba(0,229,255,.12);
  transition: all .25s;
}
body.dark-mode .topbar { background: var(--navbar-bg); border-color: #0ea5e9; box-shadow: 0 2px 12px rgba(14,165,233,.1); }

.topbar-left   { display:flex; align-items:center; gap:8px; flex:1; }
.topbar-center { display:flex; align-items:center; justify-content:center; gap:10px; flex:2; }
.topbar-right  { display:flex; align-items:center; justify-content:flex-end; gap:8px; flex:1; }

.nav-controls { display:flex; align-items:center; gap:6px; }

.nav-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius);
  background: rgba(0,0,0,.04);
  border: none; color: var(--text-primary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; text-decoration: none;
  transition: all .2s ease;
}
body.dark-mode .nav-btn { background: rgba(255,255,255,.08); }
.nav-btn:hover { background: rgba(0,229,255,.15); color: #0ea5e9; transform: translateY(-1px); }

.company-logo { height: 32px; width: auto; filter: drop-shadow(0 0 3px rgba(0,229,255,.3)); }
.company-name { font-size: 1.05rem; font-weight: 700; color: var(--navbar-text); letter-spacing: -.3px; }
.page-title   { font-size: .95rem; font-weight: 600; color: var(--text-primary); margin-left: 6px; }

/* ── Theme toggle ───────────────────────────────────────────── */
.theme-toggle-btn {
  background: rgba(0,0,0,.04);
  border: none; width: 32px; height: 32px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary); cursor: pointer; font-size: 14px;
  transition: all .2s ease;
}
body.dark-mode .theme-toggle-btn { background: rgba(255,255,255,.08); }
.theme-toggle-btn:hover { background: rgba(0,229,255,.15); color: #0ea5e9; transform: translateY(-1px); }
.theme-toggle-btn .fa-sun { display: none; }
body.dark-mode .theme-toggle-btn .fa-moon { display: none; }
body.dark-mode .theme-toggle-btn .fa-sun  { display: block; }

/* ── User avatar / dropdown ─────────────────────────────────── */
.user-profile { position: relative; }

.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa, #6366f1);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 13px; cursor: pointer;
  border: 2px solid rgba(255,255,255,.25);
  transition: all .2s;
}
.user-avatar:hover { transform: scale(1.08); box-shadow: 0 2px 10px rgba(99,102,241,.35); }

.user-dropdown,
.dropdown-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--card-bg); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); min-width: 180px;
  border: 1px solid var(--border-color); padding: 4px;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: all .2s ease;
  z-index: 1001;
}
.user-dropdown.show,
.user-profile:hover .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }

.user-dropdown-item,
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius);
  color: var(--text-primary); text-decoration: none; font-size: .85rem; font-weight: 500;
  transition: all .15s; cursor: pointer; border: none; background: none; width: 100%;
}
.user-dropdown-item:hover,
.dropdown-item:hover { background: var(--bg-secondary); color: var(--accent); }
.user-dropdown-item.danger:hover { background: #fef2f2; color: var(--red); }
.user-dropdown-divider { height: 1px; background: var(--border-color); margin: 4px 0; }
.dropdown-item i { font-size: 14px; width: 16px; }

/* ── User info wrapper ──────────────────────────────────────── */
.user-info {
  display: flex; align-items: center; gap: 8px;
}
.username-text {
  color: var(--text-primary); font-weight: 600; font-size: .85rem;
  white-space: nowrap;
}

/* ── Smaller logo variant ───────────────────────────────────── */
.company-logo-small { height: 32px; width: auto; filter: drop-shadow(0 0 3px rgba(0,229,255,.3)); }

/* ── Profile settings modal ─────────────────────────────────── */
.profile-modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 10000;
  align-items: center; justify-content: center; backdrop-filter: blur(3px);
}
.profile-modal.active { display: flex; }
.profile-modal-content {
  background: var(--modal-bg); border-radius: var(--radius-lg);
  width: 90%; max-width: 420px; box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
.profile-modal-header {
  background: var(--primary-gradient); color: white;
  padding: 14px 18px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex; align-items: center; justify-content: space-between;
}
.profile-modal-header h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.profile-close {
  background: none; border: none; color: white; font-size: 22px;
  cursor: pointer; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: all .2s;
}
.profile-close:hover { background: rgba(255,255,255,.2); }
.profile-modal-body { padding: 18px 20px; }
.profile-form-group { margin-bottom: 12px; }
.profile-form-group label {
  display: block; margin-bottom: 4px; font-weight: 600;
  color: var(--text-primary); font-size: .8rem;
}
.profile-form-group input {
  padding: 8px 12px; background: var(--bg-primary);
  border: 1.5px solid var(--border-color); color: var(--text-primary);
  border-radius: var(--radius); font-size: .85rem; width: 100%;
}
.profile-form-group input:focus {
  outline: none; border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102,126,234,.1);
}
.profile-modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border-color);
  display: flex; gap: 8px; justify-content: flex-end;
}
.profile-btn {
  padding: 8px 18px; border: none; border-radius: var(--radius);
  font-size: .82rem; font-weight: 600; cursor: pointer; transition: all .2s;
}
.profile-btn-primary { background: var(--primary-gradient); color: white; }
.profile-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(102,126,234,.3); }
.profile-btn-secondary { background: var(--border-color); color: var(--text-primary); }
.profile-btn-secondary:hover { opacity: .8; }

/* ── Theme icon variants (some pages use these) ─────────────── */
.theme-icon-dark { display: none; }
body.dark-mode .theme-icon-light { display: none !important; }
body.dark-mode .theme-icon-dark { display: block !important; }

/* ── Content area ───────────────────────────────────────────── */
.content,
.main-content { padding: 20px; max-width: 1360px; margin: 0 auto; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
}

.stat-card {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.stat-card-icon {
  width: 36px; height: 36px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; margin-bottom: 8px;
}
.stat-card-value { font-size: 1.35rem; font-weight: 700; color: var(--text-primary); }
.stat-card-label { font-size: .7rem; color: var(--text-secondary); font-weight: 600;
                   text-transform: uppercase; letter-spacing: .4px; margin-top: 1px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: .8rem; font-weight: 600; cursor: pointer;
  border: none; transition: all .15s; text-decoration: none;
  white-space: nowrap; line-height: 1.4;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--primary-gradient); color: #fff; }
.btn-success   { background: var(--green); color: #fff; }
.btn-danger    { background: var(--red); color: #fff; }
.btn-warning   { background: var(--orange); color: #fff; }
.btn-secondary { background: var(--border-color); color: var(--text-primary); }
.btn-sm        { padding: 4px 10px; font-size: .75rem; }
.btn-icon      { padding: 6px; border-radius: var(--radius); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

label {
  font-size: .75rem; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .3px;
}

input, select, textarea {
  width: 100%; padding: 8px 11px; border-radius: var(--radius);
  border: 1.5px solid var(--border-color); background: var(--bg-primary);
  color: var(--text-primary); font-size: .85rem; font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99,102,241,.12);
}
body.dark-mode input, body.dark-mode select, body.dark-mode textarea {
  background: var(--bg-secondary); border-color: var(--border-color); color: var(--text-primary);
}
textarea { resize: vertical; min-height: 60px; }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; font-size: .82rem; }
thead th {
  background: var(--bg-secondary); color: var(--text-secondary);
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; padding: 8px 12px; border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-color); transition: background .12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-secondary); }
td { padding: 8px 12px; color: var(--text-primary); vertical-align: middle; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 50px; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px;
}
.badge-success  { background: #dcfce7; color: #166534; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-warning  { background: #fef9c3; color: #854d0e; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-purple   { background: #ede9fe; color: #5b21b6; }
.badge-gray     { background: #f1f5f9; color: #475569; }
.badge-income   { background: #dcfce7; color: #166534; }
.badge-expense  { background: #fee2e2; color: #991b1b; }
.badge-asset    { background: #dbeafe; color: #1e40af; }
.badge-liability{ background: #fef9c3; color: #854d0e; }
.badge-equity   { background: #ede9fe; color: #5b21b6; }
.badge-sale     { background: #dcfce7; color: #166534; }
.badge-purchase { background: #dbeafe; color: #1e40af; }
.badge-manual   { background: #f1f5f9; color: #475569; }

body.dark-mode .badge-success   { background: #1c4532; color: #68d391; }
body.dark-mode .badge-danger    { background: #63171b; color: #fc8181; }
body.dark-mode .badge-warning   { background: #5f3d00; color: #f6e05e; }
body.dark-mode .badge-info      { background: #1a365d; color: #63b3ed; }
body.dark-mode .badge-purple    { background: #3b1e6d; color: #b794f4; }
body.dark-mode .badge-gray      { background: #4a5568; color: #e2e8f0; }
body.dark-mode .badge-income    { background: #1c4532; color: #68d391; }
body.dark-mode .badge-expense   { background: #63171b; color: #fc8181; }
body.dark-mode .badge-asset     { background: #1a365d; color: #63b3ed; }
body.dark-mode .badge-liability { background: #5f3d00; color: #f6e05e; }
body.dark-mode .badge-equity    { background: #3b1e6d; color: #b794f4; }
body.dark-mode .badge-sale      { background: #1c4532; color: #68d391; }
body.dark-mode .badge-purchase  { background: #1a365d; color: #63b3ed; }
body.dark-mode .badge-manual    { background: #4a5568; color: #e2e8f0; }

/* ── Modals ─────────────────────────────────────────────────── */
.modal {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.4); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 16px;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 0; max-width: 560px; width: 100%;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border-color);
  animation: modalIn .2s ease;
  max-height: 90vh; overflow-y: auto;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.97) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: .95rem; font-weight: 700; color: var(--text-primary); }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  border: none; background: var(--border-color); color: var(--text-primary);
  cursor: pointer; font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.modal-close:hover { background: var(--red); color: #fff; }
.modal-body   { padding: 18px; }
.modal-footer {
  padding: 12px 18px; border-top: 1px solid var(--border-color);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  background: var(--text-primary); color: var(--card-bg);
  padding: 10px 16px; border-radius: var(--radius);
  font-size: .82rem; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(12px);
  transition: all .25s ease;
  display: flex; align-items: center; gap: 8px; max-width: 320px;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.success { background: #166534; color: #fff; }
.toast.error   { background: #991b1b; color: #fff; }
.toast.warning { background: #854d0e; color: #fff; }

/* ── Section header ─────────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; flex-wrap: wrap; gap: 8px;
}
.section-header h2 { font-size: .95rem; font-weight: 700; color: var(--text-primary); }

/* ── Page header ────────────────────────────────────────────── */
.page-header {
  padding: 16px 20px; background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
}
.page-header h1 { font-size: 1.15rem; font-weight: 700; }

/* ── Summary stats row ──────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 16px;
}

/* ── Filters bar ────────────────────────────────────────────── */
.filters {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  background: var(--card-bg); padding: 10px 14px;
  border-radius: var(--radius); margin-bottom: 12px;
  border: 1px solid var(--border-color);
}
.filters input, .filters select {
  flex: 1; min-width: 100px; max-width: 180px;
  padding: 6px 10px; font-size: .8rem;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-secondary);
}
.empty-state i { font-size: 2.2rem; margin-bottom: 10px; opacity: .35; }
.empty-state p { font-size: .88rem; }

/* ── Spinner ────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-color); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Status colours ─────────────────────────────────────────── */
.status-draft     { color: #64748b; }
.status-confirmed { color: var(--blue); }
.status-delivered { color: var(--green); }
.status-cancelled { color: var(--red); }
.status-pending   { color: var(--orange); }
.status-approved  { color: var(--green); }
.status-received  { color: var(--green); }
.status-paid      { color: var(--green); }
.status-unpaid    { color: var(--red); }

/* ── Amount colours ─────────────────────────────────────────── */
.amount-positive { color: var(--green); }
.amount-negative { color: var(--red); }
.amount-neutral  { color: var(--blue); }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Responsive helpers ─────────────────────────────────────── */
@media (max-width:768px) {
  .topbar { padding: 6px 12px; }
  .topbar-center { display: none; }
  .content, .main-content { padding: 12px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .table-wrap { border-radius: 0; }
}

@media (max-width:480px) {
  .stats-row { grid-template-columns: 1fr; }
  .modal-box { border-radius: var(--radius); }
}

/* ── Print styles ───────────────────────────────────────────── */
@media print {
  .topbar, .btn, .filters, .modal, .toast, .nav-btn { display: none !important; }
  .content, .main-content { padding: 0; max-width: none; }
  body { background: #fff; }
  table { font-size: 10px; }
}
