/**
 * Twingital Directory - Frontend Styles
 * Path: assets/frontend-style.css
 */

/* ==========================================
   CSS VARIABLES (Controlled from Admin)
   ========================================== */

:root {
    --td-primary-color: #3b82f6;
    --td-secondary-color: #10b981;
    --td-accent-color: #f59e0b;
    --td-text-color: #1f2937;
    --td-background-color: #ffffff;
    --td-card-background: #f9fafb;
    --td-button-radius: 8px;
    --td-card-radius: 12px;
}

/* ==========================================
   DIRECTORY CONTAINER
   ========================================== */

.td-directory-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    background: var(--td-background-color);
}

.td-directory-header {
    text-align: center;
    margin-bottom: 50px;
}

.td-directory-title {
    font-size: 42px;
    font-weight: 800;
    color: var(--td-text-color);
    margin-bottom: 16px;
    line-height: 1.2;
}

.td-directory-subtitle {
    font-size: 18px;
    color: #6b7280;
    max-width: 600px;
    margin: 0 auto;
}

/* ==========================================
   FILTERS SECTION
   ========================================== */

.td-filters-section {
    background: white;
    padding: 30px;
    border-radius: var(--td-card-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 40px;
}

.td-filters-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.td-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.td-filter-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--td-text-color);
}

.td-search-input,
.td-filter-select {
    padding: 14px 18px;
    border: 2px solid #e5e7eb;
    border-radius: var(--td-button-radius);
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
}

.td-search-input:focus,
.td-filter-select:focus {
    outline: none;
    border-color: var(--td-primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.td-filter-actions {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.td-btn {
    padding: 14px 24px;
    border: none;
    border-radius: var(--td-button-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.td-btn-primary {
    background: var(--td-primary-color);
    color: white;
}

.td-btn-primary:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.td-btn-secondary {
    background: #e5e7eb;
    color: var(--td-text-color);
}

.td-btn-secondary:hover {
    background: #d1d5db;
}

/* Results Info */
.td-results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    color: #6b7280;
    font-size: 14px;
}

.td-results-count {
    font-weight: 600;
    color: var(--td-text-color);
}

/* ==========================================
   COMPANIES GRID
   ========================================== */

.td-companies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

/* ==========================================
   COMPANY CARD
   ========================================== */

.td-company-card {
    background: var(--td-card-background);
    border-radius: var(--td-card-radius);
    padding: 28px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}

.td-company-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--td-primary-color), var(--td-secondary-color));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.td-company-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.td-company-card:hover::before {
    transform: scaleX(1);
}

/* Card Header */
.td-card-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.td-company-logo {
    width: 70px;
    height: 70px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.td-company-logo-placeholder {
    width: 70px;
    height: 70px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--td-primary-color), var(--td-secondary-color));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 24px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.td-card-header-content {
    flex: 1;
    min-width: 0;
}

.td-company-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--td-text-color);
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.td-company-category {
    display: inline-block;
    padding: 4px 12px;
    background: var(--td-primary-color);
    color: white;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Card Body */
.td-card-body {
    margin-bottom: 20px;
}

.td-company-description {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.td-company-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.td-meta-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #374151;
}

.td-meta-icon {
    width: 18px;
    height: 18px;
    color: #6b7280;
    flex-shrink: 0;
}

.td-meta-item a {
    color: var(--td-primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

.td-meta-item a:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* Card Footer */
.td-card-footer {
    display: flex;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.td-btn-small {
    padding: 10px 18px;
    font-size: 13px;
    flex: 1;
    justify-content: center;
}

/* ==========================================
   MAP VIEW
   ========================================== */

.td-map-container {
    background: white;
    border-radius: var(--td-card-radius);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 40px;
}

.td-map-wrapper {
    width: 100%;
    height: 500px;
    position: relative;
}

#td-directory-map {
    width: 100%;
    height: 100%;
}

/* ==========================================
   SUBMISSION FORM
   ========================================== */

.td-submission-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
}

.td-form-card {
    background: white;
    border-radius: var(--td-card-radius);
    padding: 40px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.td-form-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--td-text-color);
    margin-bottom: 12px;
}

.td-form-description {
    color: #6b7280;
    margin-bottom: 40px;
    font-size: 16px;
}

.td-form-section {
    margin-bottom: 35px;
}

.td-form-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--td-text-color);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
}

.td-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.td-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.td-form-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--td-text-color);
}

.td-form-label .required {
    color: #ef4444;
    margin-left: 2px;
}

.td-form-input,
.td-form-textarea,
.td-form-select {
    padding: 14px 18px;
    border: 2px solid #e5e7eb;
    border-radius: var(--td-button-radius);
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.td-form-input:focus,
.td-form-textarea:focus,
.td-form-select:focus {
    outline: none;
    border-color: var(--td-primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.td-form-textarea {
    resize: vertical;
    min-height: 120px;
}

.td-form-help {
    font-size: 13px;
    color: #6b7280;
}

/* Map Selector */
.td-map-selector {
    margin-top: 12px;
}

.td-location-map {
    width: 100%;
    height: 350px;
    border-radius: var(--td-button-radius);
    border: 2px solid #e5e7eb;
    overflow: hidden;
}

.td-map-hint {
    margin-top: 12px;
    padding: 12px 16px;
    background: #eff6ff;
    border-left: 4px solid var(--td-primary-color);
    border-radius: 6px;
    font-size: 13px;
    color: #1e40af;
}

/* Form Actions */
.td-form-actions {
    display: flex;
    gap: 16px;
    padding-top: 30px;
    border-top: 2px solid #e5e7eb;
}

.td-btn-large {
    padding: 16px 40px;
    font-size: 16px;
}

/* Image Upload Section */
.td-file-upload-wrapper {
    margin-top: 10px;
}

.td-file-input {
    display: none;
}

.td-file-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background: var(--td-primary-color);
    color: white;
    border-radius: var(--td-button-radius);
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    font-size: 14px;
}

.td-file-upload-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.td-file-preview {
    margin-top: 15px;
    position: relative;
}

.td-file-preview img {
    max-width: 250px;
    height: auto;
    border-radius: var(--td-card-radius);
    border: 3px solid #e5e7eb;
    transition: all 0.3s;
}

.td-file-preview img:hover {
    border-color: var(--td-primary-color);
    transform: scale(1.02);
}

.td-file-preview .remove-image {
    position: absolute;
    top: -10px;
    right: calc(100% - 260px);
    background: #ef4444;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.2s;
}

.td-file-preview .remove-image:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.td-gallery-preview {
    margin-top: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.td-gallery-preview .gallery-item {
    position: relative;
    aspect-ratio: 1;
}

.td-gallery-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--td-card-radius);
    border: 3px solid #e5e7eb;
    transition: all 0.3s;
}

.td-gallery-preview img:hover {
    border-color: var(--td-primary-color);
    transform: scale(1.05);
}

.td-gallery-preview .remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s;
}

.td-gallery-preview .remove-image:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.td-upload-progress {
    margin-top: 15px;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 15px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    margin-bottom: 8px;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--td-primary-color), var(--td-secondary-color));
    width: var(--progress, 0%);
    transition: width 0.3s;
}

.progress-text {
    font-size: 13px;
    color: #6b7280;
    font-weight: 600;
}

/* ==========================================
   LOADING & EMPTY STATES
   ========================================== */

.td-loading {
    text-align: center;
    padding: 80px 20px;
}

.td-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--td-primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.td-loading-text {
    color: #6b7280;
    font-size: 16px;
}

.td-empty-state {
    text-align: center;
    padding: 80px 20px;
}

.td-empty-icon {
    font-size: 80px;
    color: #d1d5db;
    margin-bottom: 20px;
}

.td-empty-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--td-text-color);
    margin-bottom: 12px;
}

.td-empty-text {
    color: #6b7280;
    font-size: 16px;
    margin-bottom: 30px;
}

/* ==========================================
   ALERTS & NOTIFICATIONS
   ========================================== */

.td-alert {
    padding: 16px 20px;
    border-radius: var(--td-button-radius);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.td-alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.td-alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.td-alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.td-alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

/* ==========================================
   BADGES
   ========================================== */

.td-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.td-badge-featured {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
}

.td-badge-new {
    background: var(--td-secondary-color);
    color: white;
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 1024px) {
    .td-filters-grid {
        grid-template-columns: 1fr 1fr;
    }

    .td-filter-group:first-child {
        grid-column: 1 / -1;
    }

    .td-companies-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

@media (max-width: 768px) {
    .td-directory-container {
        padding: 30px 16px;
    }

    .td-directory-title {
        font-size: 32px;
    }

    .td-directory-subtitle {
        font-size: 16px;
    }

    .td-filters-section {
        padding: 20px;
    }

    .td-filters-grid {
        grid-template-columns: 1fr;
    }

    .td-filter-group:first-child {
        grid-column: 1;
    }

    .td-filter-actions {
        flex-direction: column;
    }

    .td-btn {
        width: 100%;
    }

    .td-companies-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .td-company-card {
        padding: 20px;
    }

    .td-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .td-card-footer {
        flex-direction: column;
    }

    .td-form-card {
        padding: 24px;
    }

    .td-form-title {
        font-size: 24px;
    }

    .td-form-row {
        grid-template-columns: 1fr;
    }

    .td-form-actions {
        flex-direction: column;
    }

    .td-map-wrapper {
        height: 350px;
    }
}

@media (max-width: 480px) {
    .td-directory-title {
        font-size: 26px;
    }

    .td-company-logo,
    .td-company-logo-placeholder {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }

    .td-company-name {
        font-size: 18px;
    }

    .td-form-card {
        padding: 20px;
    }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    .td-filters-section,
    .td-card-footer,
    .td-form-actions {
        display: none;
    }

    .td-company-card {
        break-inside: avoid;
    }
}

/* ==========================================
   USER DASHBOARD
   ========================================== */

.td-user-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.td-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--td-card-radius);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    color: white;
}

.td-user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.td-user-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.td-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.td-user-details h1 {
    margin: 0 0 8px 0;
    font-size: 28px;
    color: white;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.td-user-details p {
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
}

.td-dashboard-header .td-btn {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.td-dashboard-header .td-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.td-dashboard-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
    background: white;
    padding: 8px;
    border-radius: var(--td-card-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.td-dashboard-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: calc(var(--td-card-radius) - 4px);
    text-decoration: none;
    color: #6b7280;
    font-weight: 600;
    transition: all 0.3s;
}

.td-dashboard-tab:hover {
    background: #f9fafb;
    color: var(--td-primary-color);
}

.td-dashboard-tab.active {
    background: var(--td-primary-color);
    color: white;
}

.td-dashboard-tab svg {
    flex-shrink: 0;
}

.td-dashboard-content {
    background: white;
    border-radius: var(--td-card-radius);
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.td-dashboard-section {
    min-height: 400px;
}

/* Companies List */
.td-companies-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.td-user-company-card {
    background: white;
    border: 2px solid #f3f4f6;
    border-radius: var(--td-card-radius);
    padding: 28px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.td-user-company-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--td-primary-color), var(--td-secondary-color));
    opacity: 0;
    transition: opacity 0.3s;
}

.td-user-company-card:hover {
    border-color: var(--td-primary-color);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    transform: translateX(4px);
}

.td-user-company-card:hover::before {
    opacity: 1;
}

.td-company-card-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.td-company-header-info {
    flex: 1;
    min-width: 0;
}

.td-company-header-info h3 {
    margin: 0 0 10px 0;
    font-size: 20px;
    color: var(--td-text-color);
}

.td-company-meta-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.td-company-actions {
    display: flex;
    gap: 8px;
}

.td-btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
}

.td-btn-icon:hover {
    border-color: var(--td-primary-color);
    color: var(--td-primary-color);
    transform: translateY(-2px);
}

.td-delete-user-company:hover {
    border-color: #ef4444;
    color: #ef4444;
}

.td-company-card-body {
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.td-company-description {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.td-company-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.td-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
}

.td-info-item svg {
    flex-shrink: 0;
    color: #6b7280;
}

/* Dashboard Form */
.td-user-dashboard .td-form-card {
    background: transparent;
    padding: 0;
    box-shadow: none;
}

.td-user-dashboard .td-form-title {
    font-size: 24px;
    margin-bottom: 30px;
}

/* Responsive Dashboard */
@media (max-width: 768px) {
    .td-user-dashboard {
        padding: 20px 12px;
    }

    .td-dashboard-header {
        flex-direction: column;
        text-align: center;
        gap: 20px;
        padding: 20px;
    }

    .td-user-info {
        flex-direction: column;
    }

    .td-dashboard-tabs {
        flex-direction: column;
    }

    .td-dashboard-tab {
        justify-content: flex-start;
    }

    .td-dashboard-content {
        padding: 20px;
    }

    .td-company-card-header {
        flex-wrap: wrap;
    }

    .td-company-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .td-company-info-grid {
        grid-template-columns: 1fr;
    }
}