/* 
   Township Market - Main Stylesheet
   Mobile-first, optimized for low-data usage
*/

:root {
    --primary-color: #003da5;
    --secondary-color: #ff6b35;
    --success-color: #06b6d4;
    --danger-color: #ef4444;
    --warning-color: #eab308;
    --light-bg: #f3f4f6;
    --dark-text: #1f2937;
    --border-color: #d1d5db;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.5;
    color: var(--dark-text);
    background-color: #ffffff;
}

/* Optimize for low data usage */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Header & Navigation */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    color: white;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.5rem;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 1rem;
}

nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

nav a:hover {
    background-color: rgba(255,255,255,0.1);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Main Content */
main {
    min-height: calc(100vh - 200px);
    padding: 1.5rem 0;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    margin-bottom: 2rem;
    border-radius: 8px;
}

.hero h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.hero p {
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* Button Styles */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #002563;
}

.btn-secondary {
    background-color: var(--secondary-color);
}

.btn-secondary:hover {
    background-color: #e55a2b;
}

.btn-success {
    background-color: var(--success-color);
}

.btn-success:hover {
    background-color: #0891b2;
}

.btn-danger {
    background-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.2rem;
}

label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    color: var(--dark-text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="phone"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 61, 165, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Alert Messages */
.alert {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background-color: #fef3c7;
    color: #78350f;
    border: 1px solid #fde68a;
}

.alert-info {
    background-color: #cffafe;
    color: #164e63;
    border: 1px solid #a5f3fc;
}

/* Product Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.product-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.product-image {
    width: 100%;
    height: 150px;
    background-color: var(--light-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    padding: 0.75rem;
}

.product-name {
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-seller {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 0.3rem;
}

.product-price {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

.product-rating {
    font-size: 0.8rem;
    color: var(--warning-color);
    margin-bottom: 0.5rem;
}

.product-actions {
    display: flex;
    gap: 0.5rem;
}

.product-actions .btn {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.8rem;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

thead {
    background-color: var(--light-bg);
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    color: var(--dark-text);
}

tbody tr:hover {
    background-color: var(--light-bg);
}

/* Card Styles */
.card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--light-bg);
}

.card-title {
    font-size: 1.3rem;
    font-weight: 600;
}

/* Footer */
footer {
    background-color: #1f2937;
    color: #f3f4f6;
    padding: 2rem 1rem;
    margin-top: 3rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.footer-section h3 {
    margin-bottom: 0.75rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section a {
    color: #9ca3af;
    text-decoration: none;
    display: block;
    margin-bottom: 0.5rem;
}

.footer-section a:hover {
    color: white;
}

.footer-bottom {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid #374151;
    color: #9ca3af;
}

/* Responsive Design */
@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    .nav-toggle {
        display: block;
    }

    nav ul {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--primary-color);
        flex-direction: column;
        gap: 0;
        display: none;
    }

    nav ul.active {
        display: flex;
    }

    nav a {
        display: block;
        padding: 0.75rem 1rem;
        border-radius: 0;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 0.75rem;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 12px;
    }

    header {
        padding: 0.5rem 0.75rem;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.5rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .card {
        padding: 1rem;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }

.hidden {
    display: none;
}

.flex {
    display: flex;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.text-muted {
    color: #6b7280;
}

.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-primary {
    background-color: #dbeafe;
    color: #0c4a6e;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background-color: #fef3c7;
    color: #78350f;
}

.rating {
    color: var(--warning-color);
    font-weight: 600;
}

.loader {
    border: 4px solid var(--light-bg);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Print Styles for low-data mode */
@media print {
    header, footer, nav, .btn, .form-group input {
        display: none;
    }
    
    body {
        font-size: 12pt;
    }
}
