/* CSS Variables */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #64748b;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --dark: #1e293b;
  --light: #f8fafc;
  --white: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --radius: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--light);
  color: var(--dark);
  line-height: 1.6;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--dark);
  color: var(--white);
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 20px;
}

.sidebar-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header h1 span {
  color: var(--primary);
}

.sidebar-user {
  padding: 15px 20px;
  background: rgba(255,255,255,0.05);
  margin: 0 10px 20px;
  border-radius: var(--radius);
}

.sidebar-user .user-email {
  font-size: 0.875rem;
  opacity: 0.8;
}

.sidebar-user .user-role {
  font-size: 0.75rem;
  background: var(--primary);
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
  margin-top: 5px;
}

.sidebar-user .user-balance {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--success);
  margin-top: 10px;
}

.sidebar-user .user-balance.low-balance {
  color: var(--danger);
}

.nav-section {
  margin-bottom: 20px;
}

.nav-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  opacity: 0.5;
  padding: 0 20px;
  margin-bottom: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: var(--white);
}

.nav-item.active {
  background: var(--primary);
  color: var(--white);
}

.nav-item i {
  width: 20px;
  text-align: center;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 30px;
}

/* Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
}

.page-subtitle {
  color: var(--secondary);
  font-size: 0.875rem;
}

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

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

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .stat-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 15px;
}

.stat-card .stat-icon.primary { background: rgba(99,102,241,0.1); color: var(--primary); }
.stat-card .stat-icon.success { background: rgba(34,197,94,0.1); color: var(--success); }
.stat-card .stat-icon.warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.stat-card .stat-icon.info { background: rgba(59,130,246,0.1); color: var(--info); }
.stat-card .stat-icon.danger { background: rgba(239,68,68,0.1); color: var(--danger); }

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 5px;
}

.stat-card .stat-label {
  color: var(--secondary);
  font-size: 0.875rem;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--secondary);
  font-size: 0.875rem;
  text-transform: uppercase;
}

tr:hover {
  background: var(--light);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--dark);
}

.btn-outline:hover {
  background: var(--light);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}

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

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  font-size: 0.875rem;
}

.form-control {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

.form-control-sm {
  padding: 6px 10px;
}

select.form-control {
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success { background: rgba(34,197,94,0.1); color: var(--success); }
.badge-danger { background: rgba(239,68,68,0.1); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.badge-info { background: rgba(59,130,246,0.1); color: var(--info); }
.badge-primary { background: rgba(99,102,241,0.1); color: var(--primary); }

/* Alerts */
.alert {
  padding: 15px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success { background: rgba(34,197,94,0.1); color: var(--success); border: 1px solid var(--success); }
.alert-danger { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid var(--danger); }
.alert-warning { background: rgba(245,158,11,0.1); color: var(--warning); border: 1px solid var(--warning); }
.alert-info { background: rgba(59,130,246,0.1); color: var(--info); border: 1px solid var(--info); }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-20px);
  transition: transform 0.3s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--secondary);
}

.modal-body {
  padding: 20px;
}

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

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo h1 {
  font-size: 2rem;
  color: var(--dark);
}

.login-logo span {
  color: var(--primary);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 12px 20px;
  cursor: pointer;
  color: var(--secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--dark);
}

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

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 20px;
}

.pagination button {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: var(--radius);
  cursor: pointer;
}

.pagination button.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--secondary);
}

.empty-state i {
  font-size: 4rem;
  margin-bottom: 20px;
  opacity: 0.3;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
}

.toast {
  background: var(--white);
  border-radius: var(--radius);
  padding: 15px 20px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s;
  max-width: 350px;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Message Item */
.message-item {
  padding: 15px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 15px;
}

.message-item:hover {
  background: var(--light);
}

.message-item:last-child {
  border-bottom: none;
}

.message-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-icon.inbound {
  background: rgba(34,197,94,0.1);
  color: var(--success);
}

.message-icon.outbound {
  background: rgba(59,130,246,0.1);
  color: var(--info);
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.message-from {
  font-weight: 600;
}

.message-time {
  font-size: 0.75rem;
  color: var(--secondary);
}

.message-body {
  color: var(--secondary);
  font-size: 0.875rem;
  word-break: break-word;
}

.message-meta {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Number Card */
.number-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.number-info h4 {
  font-size: 1.125rem;
  margin-bottom: 5px;
}

.number-info p {
  font-size: 0.875rem;
  color: var(--secondary);
}

.number-actions {
  display: flex;
  gap: 10px;
}

/* Template Card */
.template-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 10px;
}

.template-card h4 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.template-card p {
  font-size: 0.875rem;
  color: var(--secondary);
  margin-bottom: 10px;
}

.template-actions {
  display: flex;
  gap: 10px;
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Section Visibility */
.section {
  display: none;
}

.section.active {
  display: block;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .app-container {
    flex-direction: column;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
}
