/* =========================================
   Y! Invoice — Main Stylesheet v1.0.0
   SCREAMED OUT STUDIOS
   ========================================= */

:root {
  --yi-brand: #6366f1;
  --yi-brand-dark: #4f46e5;
  --yi-brand-light: #e0e7ff;
  --yi-dark: #1a1a2e;
  --yi-dark2: #16213e;
  --yi-text: #1f2937;
  --yi-text-muted: #6b7280;
  --yi-border: #e5e7eb;
  --yi-bg: #f4f5f7;
  --yi-bg-card: #ffffff;
  --yi-radius: 12px;
  --yi-radius-sm: 8px;
  --yi-shadow: 0 2px 16px rgba(0,0,0,.07);
  --yi-shadow-lg: 0 8px 40px rgba(0,0,0,.12);
  --yi-success: #10b981;
  --yi-error: #ef4444;
  --yi-warning: #f59e0b;
  --yi-transition: all .2s ease;
}

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

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif; font-size: 15px; color: var(--yi-text); background: var(--yi-bg); }

a { color: var(--yi-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- App wrapper ---- */
.yi-app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- Loading Spinner ---- */
.yi-loading { position: fixed; inset: 0; background: rgba(255,255,255,.85); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.yi-spinner { width: 40px; height: 40px; border: 4px solid var(--yi-brand-light); border-top-color: var(--yi-brand); border-radius: 50%; animation: yi-spin .7s linear infinite; }
@keyframes yi-spin { to { transform: rotate(360deg); } }

/* ---- Navigation ---- */
.yi-nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--yi-dark);
  padding: 0 24px;
  height: 60px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
}
.yi-nav-brand { flex-shrink: 0; }
.yi-logo-text { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.yi-logo-text .accent { color: var(--yi-brand); }
.yi-logo-text.large { font-size: 32px; }
.yi-nav-links { display: flex; gap: 4px; flex: 1; }
.yi-nav-link { padding: 6px 14px; border-radius: 6px; font-size: 14px; font-weight: 500; color: rgba(255,255,255,.7); transition: var(--yi-transition); }
.yi-nav-link:hover, .yi-nav-link.active { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.yi-nav-user { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.yi-credits-badge { background: rgba(99,102,241,.25); color: var(--yi-brand-light); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 50px; white-space: nowrap; }
.yi-btn-icon { background: none; border: none; color: rgba(255,255,255,.6); cursor: pointer; font-size: 18px; padding: 4px 8px; border-radius: 6px; transition: var(--yi-transition); }
.yi-btn-icon:hover { color: #fff; background: rgba(255,255,255,.1); }
.yi-mobile-menu-btn { display: none; background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; margin-left: auto; }
.yi-back-link { color: rgba(255,255,255,.7); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.yi-back-link:hover { color: #fff; text-decoration: none; }
.yi-nav-title { color: #fff; font-weight: 600; font-size: 15px; flex: 1; }

/* ---- Main content ---- */
.yi-main { flex: 1; padding: 32px 24px; max-width: 1200px; width: 100%; margin: 0 auto; }
.yi-page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.yi-page-title { font-size: 26px; font-weight: 700; color: var(--yi-dark); }

/* ---- Buttons ---- */
.yi-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px; border-radius: 50px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: var(--yi-transition); text-decoration: none !important; white-space: nowrap; }
.yi-btn:disabled { opacity: .5; cursor: not-allowed; }
.yi-btn-primary { background: var(--yi-brand); color: #fff; }
.yi-btn-primary:hover:not(:disabled) { background: var(--yi-brand-dark); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(99,102,241,.35); }
.yi-btn-secondary { background: #f3f4f6; color: var(--yi-text); }
.yi-btn-secondary:hover { background: #e5e7eb; }
.yi-btn-outline { background: transparent; color: var(--yi-brand); border: 2px solid var(--yi-brand); }
.yi-btn-outline:hover { background: var(--yi-brand-light); }
.yi-btn-danger { background: var(--yi-error); color: #fff; }
.yi-btn-danger:hover { background: #dc2626; }
.yi-btn-full { width: 100%; justify-content: center; }
.yi-btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 6px; }

/* ---- Cards ---- */
.yi-card { background: var(--yi-bg-card); border-radius: var(--yi-radius); box-shadow: var(--yi-shadow); padding: 24px; margin-bottom: 24px; }
.yi-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.yi-card-title { font-size: 18px; font-weight: 700; color: var(--yi-dark); }
.yi-card-footer { border-top: 1px solid var(--yi-border); padding-top: 20px; margin-top: 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.yi-link { font-size: 14px; font-weight: 500; }

/* ---- Stats Grid ---- */
.yi-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.yi-stat-card { background: var(--yi-bg-card); border-radius: var(--yi-radius); box-shadow: var(--yi-shadow); padding: 20px; display: flex; align-items: center; gap: 16px; transition: var(--yi-transition); }
.yi-stat-card:hover { transform: translateY(-2px); box-shadow: var(--yi-shadow-lg); }
.yi-stat-loading { opacity: .7; }
.yi-stat-icon { font-size: 32px; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; background: var(--yi-brand-light); border-radius: var(--yi-radius-sm); flex-shrink: 0; }
.yi-stat-value { font-size: 24px; font-weight: 800; color: var(--yi-dark); line-height: 1; }
.yi-stat-label { font-size: 13px; color: var(--yi-text-muted); margin-top: 4px; }

/* ---- Table ---- */
.yi-table-wrapper { overflow-x: auto; }
.yi-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.yi-table thead th { padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--yi-text-muted); border-bottom: 2px solid var(--yi-border); background: #f9fafb; }
.yi-table tbody td { padding: 13px 14px; border-bottom: 1px solid #f3f4f6; font-size: 14px; color: var(--yi-text); }
.yi-table tbody tr:hover { background: #f9fafb; }
.yi-table-empty { text-align: center; color: var(--yi-text-muted); font-size: 14px; padding: 40px 0; }
.yi-table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- Status Badges ---- */
.yi-badge { display: inline-block; padding: 3px 10px; border-radius: 50px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.yi-badge-draft { background: #f3f4f6; color: #6b7280; }
.yi-badge-sent { background: #eff6ff; color: #3b82f6; }
.yi-badge-viewed { background: #f0fdf4; color: #16a34a; }
.yi-badge-paid { background: #d1fae5; color: #059669; }
.yi-badge-cancelled { background: #fef2f2; color: #ef4444; }
.yi-badge-open { background: #fef3c7; color: #d97706; }
.yi-badge-answered { background: #eff6ff; color: #3b82f6; }
.yi-badge-closed { background: #f3f4f6; color: #6b7280; }

/* ---- Forms ---- */
.yi-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 4px; }
.yi-form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.yi-form-group--full { grid-column: 1 / -1; }
.yi-form-group label { font-size: 13px; font-weight: 600; color: var(--yi-text-muted); text-transform: uppercase; letter-spacing: .4px; }
.yi-input { width: 100%; padding: 10px 14px; border: 1.5px solid var(--yi-border); border-radius: var(--yi-radius-sm); font-size: 14px; color: var(--yi-text); background: #fff; transition: var(--yi-transition); font-family: inherit; }
.yi-input:focus { outline: none; border-color: var(--yi-brand); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
textarea.yi-input { resize: vertical; min-height: 80px; }
select.yi-input { cursor: pointer; }
.yi-form-hint { font-size: 13px; color: var(--yi-text-muted); margin-bottom: 16px; }
.required { color: var(--yi-error); }
.yi-checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--yi-text-muted); cursor: pointer; }
.yi-password-wrap { position: relative; }
.yi-password-wrap .yi-input { padding-right: 44px; }
.yi-toggle-password { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 16px; color: var(--yi-text-muted); }

/* ---- Password strength ---- */
.yi-password-strength { height: 4px; border-radius: 2px; margin-top: 6px; transition: all .3s; background: #e5e7eb; }
.yi-password-strength.weak { background: var(--yi-error); width: 30%; }
.yi-password-strength.medium { background: var(--yi-warning); width: 65%; }
.yi-password-strength.strong { background: var(--yi-success); width: 100%; }

/* ---- Feedback messages ---- */
.yi-feedback { padding: 12px 16px; border-radius: var(--yi-radius-sm); font-size: 14px; margin-bottom: 16px; }
.yi-feedback--error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.yi-feedback--success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* ---- Toast ---- */
.yi-toast { position: fixed; bottom: 24px; right: 24px; padding: 14px 22px; background: var(--yi-dark); color: #fff; border-radius: var(--yi-radius-sm); font-size: 14px; font-weight: 500; z-index: 9999; opacity: 0; transform: translateY(12px); transition: all .3s ease; pointer-events: none; max-width: 340px; box-shadow: var(--yi-shadow-lg); }
.yi-toast.show { opacity: 1; transform: translateY(0); }
.yi-toast.success { background: var(--yi-success); }
.yi-toast.error { background: var(--yi-error); }

/* ---- Modals ---- */
.yi-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.yi-modal.open { display: flex; }
.yi-modal-box { background: #fff; border-radius: var(--yi-radius); box-shadow: var(--yi-shadow-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; animation: yi-modal-in .2s ease; }
@keyframes yi-modal-in { from { transform: scale(.94) translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.yi-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--yi-border); }
.yi-modal-header h3 { font-size: 18px; font-weight: 700; }
.yi-modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--yi-text-muted); padding: 4px 8px; border-radius: 6px; transition: var(--yi-transition); }
.yi-modal-close:hover { background: #f3f4f6; color: var(--yi-text); }
.yi-modal-body { padding: 24px; }
.yi-modal-footer { padding: 16px 24px; border-top: 1px solid var(--yi-border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Share URL box ---- */
.yi-share-url-box { display: flex; gap: 8px; margin-bottom: 16px; }
.yi-share-url-box .yi-input { flex: 1; font-size: 13px; }
.yi-share-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.yi-share-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: var(--yi-transition); text-decoration: none; }
.yi-share-whatsapp { background: #25d366; color: #fff; }
.yi-share-telegram { background: #229ed9; color: #fff; }
.yi-share-pdf { background: var(--yi-dark); color: #fff; }
.yi-share-email { background: var(--yi-brand); color: #fff; }
.yi-share-intro { font-size: 15px; color: var(--yi-text-muted); margin-bottom: 12px; }

/* ---- Filters ---- */
.yi-filters { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.yi-search-input { max-width: 280px; }
.yi-status-filter { max-width: 160px; }

/* ---- Pagination ---- */
.yi-pagination { display: flex; gap: 6px; justify-content: center; padding: 20px 0 4px; }
.yi-page-btn { padding: 6px 14px; border: 1.5px solid var(--yi-border); border-radius: 6px; background: #fff; font-size: 13px; cursor: pointer; transition: var(--yi-transition); }
.yi-page-btn.active, .yi-page-btn:hover { border-color: var(--yi-brand); color: var(--yi-brand); }

/* ---- Auth page ---- */
.yi-auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.yi-auth-card { padding: 60px 48px; display: flex; flex-direction: column; justify-content: center; max-width: 520px; width: 100%; margin: 0 auto; }
.yi-auth-logo { margin-bottom: 40px; text-align: center; }
.yi-auth-logo p { color: var(--yi-text-muted); margin-top: 8px; font-size: 16px; }
.yi-auth-footer { margin-top: 24px; text-align: center; font-size: 14px; color: var(--yi-text-muted); line-height: 2; }
.yi-auth-brand { background: linear-gradient(135deg, var(--yi-dark), var(--yi-dark2)); padding: 60px 48px; display: flex; align-items: center; justify-content: center; }
.yi-brand-content h2 { font-size: 28px; font-weight: 800; color: #fff; margin-bottom: 28px; line-height: 1.3; }
.yi-brand-features { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.yi-brand-features li { color: rgba(255,255,255,.85); font-size: 15px; }
.yi-brand-credit { color: rgba(255,255,255,.4); font-size: 13px; margin-top: 32px; }

/* ---- Settings tabs ---- */
.yi-settings-tabs { display: flex; gap: 4px; background: var(--yi-bg-card); padding: 8px; border-radius: var(--yi-radius) var(--yi-radius) 0 0; border: 1px solid var(--yi-border); border-bottom: none; }
.yi-tab { padding: 8px 20px; border-radius: var(--yi-radius-sm); font-size: 14px; font-weight: 500; background: none; border: none; cursor: pointer; color: var(--yi-text-muted); transition: var(--yi-transition); }
.yi-tab.active { background: var(--yi-brand); color: #fff; }
.yi-tab-panel { display: none; }
.yi-tab-panel.active { display: block; }
.yi-color-input-wrap { display: flex; align-items: center; }
.yi-color-input { width: 44px; height: 38px; padding: 2px; border: 1.5px solid var(--yi-border); border-radius: var(--yi-radius-sm); cursor: pointer; }
.yi-logo-preview { margin-bottom: 12px; }
.yi-upload-zone { border: 2px dashed var(--yi-border); border-radius: var(--yi-radius-sm); padding: 28px; text-align: center; cursor: pointer; transition: var(--yi-transition); }
.yi-upload-zone:hover { border-color: var(--yi-brand); background: var(--yi-brand-light); }
.yi-upload-icon { font-size: 32px; margin-bottom: 8px; }
.yi-upload-zone p { font-size: 13px; color: var(--yi-text-muted); margin-bottom: 12px; }

/* ---- Client grid ---- */
.yi-clients-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.yi-client-card { background: #f9fafb; border: 1.5px solid var(--yi-border); border-radius: var(--yi-radius-sm); padding: 18px; transition: var(--yi-transition); }
.yi-client-card:hover { border-color: var(--yi-brand); box-shadow: 0 2px 12px rgba(99,102,241,.1); }
.yi-client-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.yi-client-email, .yi-client-phone { font-size: 13px; color: var(--yi-text-muted); }
.yi-client-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---- Support ---- */
.yi-support-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.yi-contact-card { background: linear-gradient(135deg, #f8f9ff, #fff); }
.yi-contact-grid { display: flex; gap: 32px; flex-wrap: wrap; }
.yi-contact-item { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.8; }
.yi-contact-icon { font-size: 24px; }
.yi-ticket-item { padding: 14px 0; border-bottom: 1px solid var(--yi-border); }
.yi-ticket-item:last-child { border-bottom: none; }
.yi-ticket-subject { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.yi-ticket-meta { font-size: 12px; color: var(--yi-text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.yi-ticket-reply { margin-top: 10px; background: #f0f0ff; border-left: 3px solid var(--yi-brand); padding: 10px 14px; border-radius: 0 6px 6px 0; font-size: 13px; color: var(--yi-text); }

/* ---- Mobile nav ---- */
.yi-mobile-nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 199; }
.yi-mobile-nav { position: fixed; top: 0; left: -280px; width: 280px; height: 100vh; background: var(--yi-dark); z-index: 200; transition: left .3s ease; padding: 0; overflow-y: auto; }
.yi-mobile-nav.open { left: 0; }
.yi-mobile-nav-overlay.open { display: block; }
.yi-mobile-nav-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.yi-close-nav { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }
.yi-mobile-nav-link { display: block; padding: 14px 20px; color: rgba(255,255,255,.8); font-size: 15px; font-weight: 500; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.06); transition: var(--yi-transition); background: none; border-left: none; border-right: none; border-top: none; width: 100%; text-align: left; cursor: pointer; font-family: inherit; }
.yi-mobile-nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.yi-mobile-logout { color: #f87171; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .yi-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .yi-nav-links { display: none; }
  .yi-mobile-menu-btn { display: block; }
}
@media (max-width: 768px) {
  .yi-main { padding: 20px 16px; }
  .yi-auth-page { grid-template-columns: 1fr; }
  .yi-auth-brand { display: none; }
  .yi-auth-card { padding: 40px 24px; }
  .yi-form-row { grid-template-columns: 1fr; }
  .yi-support-grid { grid-template-columns: 1fr; }
  .yi-stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .yi-stats-grid { grid-template-columns: 1fr; }
  .yi-page-title { font-size: 20px; }
}
