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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

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

/* Navbar */
.navbar {
  background: #2c3e50;
  padding: 15px 0;
  margin-bottom: 30px;
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  color: white;
  text-decoration: none;
  font-size: 1.5em;
  font-weight: bold;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.username {
  color: #bdc3c7;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 16px;
  background: #ecf0f1;
  color: #333;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.btn:hover {
  background: #bdc3c7;
}

.btn-primary {
  background: #3498db;
  color: white;
}

.btn-primary:hover {
  background: #2980b9;
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-block {
  display: block;
  width: 100%;
}

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

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #3498db;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* Alerts */
.alert {
  padding: 12px 20px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Login */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 100px);
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 400px;
}

.login-box h1 {
  text-align: center;
  color: #2c3e50;
  margin-bottom: 5px;
}

.login-box .subtitle {
  text-align: center;
  color: #7f8c8d;
  margin-bottom: 30px;
}

.carddav-info {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.carddav-info h3 {
  font-size: 14px;
  color: #7f8c8d;
  margin-bottom: 10px;
}

.carddav-info p {
  font-size: 12px;
  color: #95a5a6;
  margin-bottom: 5px;
}

.carddav-info code {
  background: #ecf0f1;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
}

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

.page-header h1 {
  color: #2c3e50;
}

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

/* Search Box */
.search-box {
  margin-bottom: 20px;
}

.search-box input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
}

/* Addressbooks */
.addressbooks-list {
  margin-bottom: 20px;
}

.addressbook-section {
  background: white;
  padding: 15px 20px;
  border-radius: 4px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.addressbook-section h2 {
  font-size: 16px;
  color: #2c3e50;
  margin-bottom: 5px;
}

.addressbook-meta {
  font-size: 12px;
  color: #95a5a6;
}

.addressbook-meta code {
  background: #ecf0f1;
  padding: 2px 6px;
  border-radius: 3px;
}

/* Contacts Table */
.contacts-table {
  width: 100%;
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border-collapse: collapse;
}

.contacts-table th,
.contacts-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.contacts-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #2c3e50;
}

.contacts-table tbody tr:hover {
  background: #f8f9fa;
}

.contacts-table a {
  color: #3498db;
  text-decoration: none;
}

.contacts-table a:hover {
  text-decoration: underline;
}

.contacts-table .actions {
  text-align: right;
  white-space: nowrap;
}

.contacts-table .actions .btn {
  margin-left: 5px;
}

.empty-message {
  text-align: center;
  color: #95a5a6;
  padding: 40px;
}

/* Contact Form */
.contact-form-container {
  background: white;
  padding: 30px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  max-width: 600px;
}

.addressbook-info {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.addressbook-info p {
  font-size: 14px;
  color: #7f8c8d;
}

.addressbook-info code {
  background: #ecf0f1;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

/* Responsive */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .contacts-table {
    display: block;
    overflow-x: auto;
  }

  .contacts-table th:nth-child(4),
  .contacts-table td:nth-child(4) {
    display: none;
  }
}

/* Help Page */
.help-section {
  background: white;
  padding: 25px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.help-section h2 {
  color: #2c3e50;
  margin-bottom: 15px;
  font-size: 18px;
}

.help-section ol {
  margin-left: 20px;
}

.help-section li {
  margin-bottom: 8px;
}

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

.info-table th,
.info-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.info-table th {
  width: 120px;
  color: #7f8c8d;
}

.info-table code {
  background: #ecf0f1;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 14px;
}

/* Addressbook Management */
.addressbooks-list h2 {
  color: #2c3e50;
  margin: 20px 0 15px 0;
  font-size: 16px;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}

.addressbook-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.addressbook-header h3 {
  margin: 0;
  font-size: 16px;
}

.addressbook-header h3 a {
  color: #2c3e50;
  text-decoration: none;
}

.addressbook-header h3 a:hover {
  color: #3498db;
}

.addressbook-actions {
  display: flex;
  gap: 5px;
}

.addressbook-section.shared {
  background: #f8f9fa;
  border-left: 3px solid #3498db;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
  vertical-align: middle;
}

.badge-read {
  background: #ecf0f1;
  color: #7f8c8d;
}

.badge-write {
  background: #d4edda;
  color: #155724;
}

/* Share Page */
.share-container {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
}

.share-form-section,
.shares-list-section {
  background: white;
  padding: 25px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.share-form-section h2,
.shares-list-section h2 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 16px;
  color: #2c3e50;
}

.share-form .form-group {
  margin-bottom: 15px;
}

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

.shares-table th,
.shares-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.shares-table th {
  background: #f8f9fa;
  font-weight: 600;
}

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

  .addressbook-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

/* Import Page */
.import-info {
  margin-bottom: 25px;
}

.import-info h2 {
  color: #2c3e50;
  margin-bottom: 10px;
  font-size: 18px;
}

.import-info p {
  color: #7f8c8d;
  margin-bottom: 10px;
}

.import-info ul {
  margin-left: 20px;
  color: #7f8c8d;
}

.import-info li {
  margin-bottom: 5px;
}

.import-notes {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.import-notes h3 {
  font-size: 14px;
  color: #7f8c8d;
  margin-bottom: 10px;
}

.import-notes ul {
  margin-left: 20px;
  color: #95a5a6;
  font-size: 13px;
}

.import-notes li {
  margin-bottom: 5px;
}

input[type="file"] {
  padding: 10px;
  border: 2px dashed #ddd;
  border-radius: 4px;
  background: #f8f9fa;
  cursor: pointer;
}

input[type="file"]:hover {
  border-color: #3498db;
}

/* Read-only form display */
.form-static {
  padding: 10px;
  background: #f8f9fa;
  border-radius: 4px;
  color: #333;
  margin: 0;
}

/* Search and Filter Row */
.search-filter-row {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
}

.search-filter-row .search-box {
  flex: 1;
  margin-bottom: 0;
}

.filter-box {
  min-width: 200px;
}

.filter-box select {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
  background: white;
}

.filter-box select:focus {
  outline: none;
  border-color: #3498db;
}

/* Contact count badge */
.contact-count {
  font-size: 14px;
  color: #7f8c8d;
  font-weight: normal;
}

/* Addressbook link in table */
.addressbook-link {
  color: #7f8c8d;
  text-decoration: none;
  font-size: 13px;
}

.addressbook-link:hover {
  color: #3498db;
  text-decoration: underline;
}

@media (max-width: 768px) {
  .search-filter-row {
    flex-direction: column;
  }

  .filter-box {
    min-width: 100%;
  }
}

/* Sync Toggle */
.sync-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 4px 10px;
  background: #ecf0f1;
  border-radius: 4px;
  font-size: 12px;
}

.sync-toggle:hover {
  background: #bdc3c7;
}

.sync-toggle input[type="checkbox"] {
  cursor: pointer;
  width: 14px;
  height: 14px;
}

.sync-label {
  color: #333;
}

.agent-toggle {
  background: #e8f4fc;
}

.agent-toggle:hover {
  background: #d4e9f7;
}
