@tailwind base;
@tailwind components;
@tailwind utilities;

/* Custom styles */
html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  width: 100%;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.animate-fadeIn {
  animation: fadeIn 0.3s ease-in-out;
}

.pb-mobile-nav {
  padding-bottom: 4rem;
}

@media (min-width: 640px) {
  .pb-mobile-nav {
    padding-bottom: 0;
  }
}

/* Dark mode styles */
body.dark {
  background-color: #111827; /* gray-900 */
}

body.dark .configs-page, 
body.dark .jobs-page {
  background-color: #111827 !important; /* gray-900 */
  min-height: 100vh;
}

#jobs-container.dark, #configs-container.dark {
  background-color: #111827 !important;
  min-height: 100vh;
}

body.dark .bg-white {
  background-color: #1f2937 !important;
}

/* Base styles */
:root {
    --primary-color: #2563eb;
    --secondary-color: #475569;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #f8fafc;
    --text-color: #1e293b;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    /* Prevent content from going under bottom nav on mobile */
    padding-bottom: env(safe-area-inset-bottom);
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Navigation */
.navbar {
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.navbar-menu {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.navbar-item {
    color: var(--secondary-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}

.navbar-item:hover {
    background-color: #f1f5f9;
}

/* Cards */
.card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

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

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s;
}

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

.button-primary:hover {
    background-color: #1d4ed8;
}

.button-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.button-secondary:hover {
    background-color: #374151;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.table th {
    background-color: #f8fafc;
    font-weight: 600;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
}

/* Grid */
.grid {
    display: grid;
    gap: 1rem;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* Footer */
.footer {
    background-color: white;
    padding: 2rem 0;
    margin-top: 2rem;
    border-top: 1px solid #e2e8f0;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    display: none;
}

.pb-mobile-nav {
    padding-bottom: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .pb-mobile-nav {
        padding-bottom: 5rem !important; /* Account for bottom nav */
    }
    
    .grid-cols-2,
    .grid-cols-3 {
        grid-template-columns: 1fr;
    }

    .navbar-menu {
        flex-direction: column;
        align-items: flex-start;
    }
    
    /* Adjust cards for mobile */
    .card {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    /* Table adjustments for mobile */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Adjust forms for mobile */
    .form-label {
        font-size: 0.875rem;
    }
    
    .form-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.625rem;
    }
    
    /* Touch-friendly buttons */
    .button {
        padding: 0.625rem 1rem;
        min-height: 44px; /* Better touch target */
    }
    
    /* Mobile spacing */
    .container {
        padding: 0.75rem;
    }
    
    .px-4 {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .py-4 {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .card-body {
        padding: 0.75rem;
    }
    
    .card-title {
        font-size: 1.125rem;
    }
    
    .hidden-xs {
        display: none;
    }
    
    /* Stack buttons on small screens */
    .button-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    /* Ensure safe area at bottom of the page */
    body {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* Support for notch phones */
@supports (padding: max(0px)) {
    body, 
    .container,
    .navbar {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .mobile-nav-container {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) {
    .mobile-bottom-nav {
        background-color: #1e293b;
        border-top-color: #334155;
    }
}

/* Improve form elements on mobile */
@media (hover: none) and (pointer: coarse) {
    input[type="checkbox"], 
    input[type="radio"],
    button,
    .button,
    select {
        min-height: 44px;
        min-width: 44px;
    }
    
    input, select, textarea {
        font-size: 16px !important; /* Prevents zoom on focus in iOS */
    }
}