/* ============================================
   PROFILE PAGE STYLES
   ============================================ */

:root {
  --bg: #000000;
  --surface: #0D0D0D;
  --text: #FFFFFF;
  --text-muted: #999999;
  --accent: #F3E4C0;
  --accent-dark: #D4C5A1;
  --success: #10b981;
  --danger: #ef4444;
  --border: #222222;
}

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

body {
  font-family: 'Montserrat', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ============================================
   NAVBAR
   ============================================ */

.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
  transition: opacity 0.3s;
}

.nav-logo:hover {
  opacity: 0.8;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.btn-logout:hover {
  background: var(--danger);
  border-color: var(--danger);
}

/* ============================================
   CONTAINER
   ============================================ */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
  margin-bottom: 3rem;
}

.page-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

/* ============================================
   PROFILE GRID
   ============================================ */

.profile-grid {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 2rem;
}

/* ============================================
   PROFILE CARD
   ============================================ */

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  height: fit-content;
  position: sticky;
  top: calc(70px + 2rem);
}

.profile-avatar {
  text-align: center;
  margin-bottom: 1.5rem;
}

.avatar-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: 0 8px 32px rgba(243, 228, 192, 0.3);
}

.avatar-initials {
  font-size: 3rem;
  font-weight: 700;
  color: #000;
}

.btn-change-avatar {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.85rem;
  transition: all 0.3s;
}

.btn-change-avatar:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.profile-info {
  text-align: center;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.profile-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.profile-role {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.profile-phone {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============================================
   INFO SECTION
   ============================================ */

.info-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s;
}

.info-card:hover {
  border-color: rgba(243, 228, 192, 0.3);
}

.info-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.info-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.info-card-body {
  padding: 1.5rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.info-value {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-active {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.status-blocked {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #D4C5A0 100%);
  color: #000;
  border: none;
  padding: 0.875rem 1.75rem;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(243, 228, 192, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(243, 228, 192, 0.35);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-secondary:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

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

.btn-full {
  width: 100%;
}

.danger-card {
  border-color: rgba(239, 68, 68, 0.3);
}

.danger-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s;
}

.modal-close:hover {
  background: var(--danger);
  color: #fff;
}

/* ============================================
   FORM
   ============================================ */

.profile-form {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
}

.checkbox-label:hover {
  background-color: rgba(243, 228, 192, 0.05);
}

.checkbox-label input[type="checkbox"] {
  margin-right: 0.5rem;
  accent-color: #F3E4C0;
  cursor: pointer;
  width: 1rem;
  height: 1rem;
}

.checkbox-label-inline {
  display: flex;
  align-items: flex-start;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox-label-inline input[type="checkbox"] {
  margin-right: 0.75rem;
  margin-top: 0.25rem;
  accent-color: #F3E4C0;
  cursor: pointer;
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

.modal-content-large {
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
}

.form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-hint {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

/* Client Details Modal */
.client-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  padding: 2rem;
}

.detail-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.detail-section-full {
  grid-column: 1 / -1;
}

.detail-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.detail-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.detail-value {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
}

.detail-value:empty::before {
  content: '—';
  color: var(--text-muted);
}

/* ============================================
   PROFILE TABS
   ============================================ */

.profile-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border);
}

.profile-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  padding: 1rem 1.5rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.3s ease;
}

.profile-tab:hover {
  color: var(--text);
  background: rgba(243, 228, 192, 0.05);
}

.profile-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================
   CLIENTS SECTION
   ============================================ */

.clients-section {
  animation: fadeIn 0.3s ease;
}

.clients-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2.5rem;
  gap: 2rem;
  flex-wrap: wrap;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Loading and Error States */
.loading-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  gap: 1rem;
}

.loader {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(243, 228, 192, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-message {
  color: var(--danger);
  font-size: 1rem;
}

/* Clients Table */
.clients-table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.clients-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.clients-table thead {
  background: rgba(243, 228, 192, 0.05);
  border-bottom: 2px solid var(--border);
}

.clients-table th {
  padding: 1.25rem 0.875rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  vertical-align: middle;
}

.clients-table th:first-child {
  padding-left: 1.5rem;
  width: 16%;
  text-align: left;
}

.clients-table th:nth-child(2) {
  width: 13%;
  text-align: center;
}

.clients-table th:nth-child(3) {
  width: 18%;
  text-align: center;
}

.clients-table th:nth-child(4) {
  width: 12%;
  text-align: center;
}

.clients-table th:nth-child(5) {
  width: 12%;
  text-align: center;
}

.clients-table th:last-child {
  width: 29%;
  text-align: center;
}

.clients-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  vertical-align: middle;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.5;
}

.clients-table td:first-child {
  padding-left: 1.5rem;
  text-align: left;
}

.clients-table td:nth-child(2) {
  text-align: center;
  font-weight: 500;
}

.clients-table td:nth-child(3) {
  text-align: center;
  font-weight: 500;
}

.clients-table td:nth-child(4) {
  text-align: center;
}

.clients-table td:nth-child(5) {
  text-align: center;
  color: var(--text-muted);
}

.clients-table td:last-child {
  text-align: center;
  padding: 1rem 0.5rem;
}

.clients-table td strong {
  font-weight: 600;
  color: var(--text);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clients-table tbody tr {
  transition: background 0.2s ease;
}

.clients-table tbody tr {
  height: 80px;
}

.clients-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.clients-table tbody tr:hover {
  background: rgba(243, 228, 192, 0.08);
}

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

.client-comment {
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.client-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
}

.btn-action {
  padding: 0.5rem 0.875rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-width: 80px;
  text-align: center;
}

.btn-action:hover {
  background: rgba(243, 228, 192, 0.12);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn-action-view {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-action-view:hover {
  background: rgba(243, 228, 192, 0.15);
  border-color: var(--accent);
}

.btn-action-edit {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-action-edit:hover {
  background: rgba(243, 228, 192, 0.15);
  border-color: var(--accent);
}

.btn-action-transfer {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-action-transfer:hover {
  background: var(--accent);
  color: var(--bg);
}

.btn-action-delete {
  border-color: rgba(239, 68, 68, 0.5);
  color: #ef4444;
}

.btn-action-delete:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}

.client-status {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  margin: 0 auto;
}

.client-status.new {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.client-status.accepted {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.client-status.in_progress {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.client-status.completed {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.client-status.rejected {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Info and Warning Boxes */
.info-box {
  background: rgba(243, 228, 192, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.info-box p {
  margin: 0.5rem 0;
  font-size: 0.9375rem;
}

.info-box strong {
  color: var(--accent);
}

.warning-box {
  background: rgba(251, 191, 36, 0.05);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: #fbbf24;
}

.required {
  color: var(--danger);
}

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

@media (max-width: 968px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
  
  .profile-card {
    position: static;
  }
}

@media (max-width: 576px) {
  .page-title {
    font-size: 2rem;
  }
  
  .avatar-circle {
    width: 100px;
    height: 100px;
  }
  
  .avatar-initials {
    font-size: 2.5rem;
  }
}

/* Table responsive improvements */
@media (max-width: 1400px) {
  .clients-table th,
  .clients-table td {
    font-size: 0.85rem;
    padding: 1rem 0.75rem;
  }
  
  .btn-action {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
    min-width: 70px;
  }
  
  .client-details-grid {
    gap: 1.5rem;
    padding: 1.5rem;
  }
}

@media (max-width: 1200px) {
  .clients-table th,
  .clients-table td {
    font-size: 0.8rem;
    padding: 0.875rem 0.625rem;
  }
  
  .btn-action {
    padding: 0.375rem 0.6rem;
    font-size: 0.75rem;
    min-width: 65px;
  }
}

@media (max-width: 968px) {
  .client-details-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 1.25rem;
  }
  
  .detail-section-full {
    grid-column: 1;
  }
}

@media (max-width: 768px) {
  .clients-table-wrapper {
    border-radius: 8px;
  }
  
  .clients-table th,
  .clients-table td {
    font-size: 0.75rem;
    padding: 0.75rem 0.5rem;
  }
  
  .clients-table th:first-child,
  .clients-table td:first-child {
    padding-left: 0.75rem;
  }
  
  .client-actions {
    flex-direction: column;
    gap: 0.375rem;
  }
  
  .client-status {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
  
  .btn-action {
    padding: 0.45rem 0.65rem;
    font-size: 0.7rem;
    width: 100%;
    min-width: unset;
    text-align: center;
  }
  
  .client-details-grid {
    padding: 1rem;
  }
  
  .detail-section {
    padding: 1rem;
  }
  
  .detail-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .detail-label {
    font-weight: 600;
  }
}

.referral-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.referral-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: stretch;
}

.referral-link-input {
  flex: 1;
  min-width: 0;
  font-size: 0.8125rem;
}

@media (max-width: 520px) {
  .referral-link-row {
    flex-direction: column;
  }
}