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

/* ====================================================
   BASE — shared by all pages
   ==================================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #2250bc 0%, #7bc880 100%);
    min-height: 100vh;
    padding: 20px;
}

/* Admin page uses a different background */
body.admin-page {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}

/* ====================================================
   BUTTONS — index defaults, admin overrides
   ==================================================== */
.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.admin-page .btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.admin-page .btn-primary:hover {
    transform: none;
    box-shadow: none;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

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

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

/* Index: outlined; Admin: solid grey */
.btn-secondary {
    background: white;
    color: #3b82f6;
    border: 2px solid #3b82f6;
}

.btn-secondary:hover {
    background: #eff6ff;
}

.admin-page .btn-secondary {
    background: #6b7280;
    color: white;
    border: none;
}

.admin-page .btn-secondary:hover {
    background: #4b5563;
}

.btn-danger-small {
    background: #ef4444;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-danger-small:hover {
    background: #dc2626;
}

/* ====================================================
   FORM GROUPS — index defaults, admin overrides
   ==================================================== */
.form-group {
    margin-bottom: 24px;
}

.admin-page .form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    font-size: 14px;
}

.admin-page .form-group label {
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s;
    background: white;
}

.admin-page .form-group input {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.admin-page .form-group input:focus {
    box-shadow: none;
}

/* Textarea is admin-only */
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s;
    min-height: 100px;
    font-family: inherit;
    resize: vertical;
}

.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

/* ====================================================
   ALERTS
   ==================================================== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* ====================================================
   SECTION TITLE — index has border, admin does not
   ==================================================== */
.section-title {
    font-size: 20px;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 3px solid #3b82f6;
}

.admin-page .section-title {
    padding-bottom: 0;
    border-bottom: none;
}

/* ====================================================
   TIER CARDS — scoped by parent container
   ==================================================== */

/* Calculator page: .tier-cards > .tier-card */
.tier-card {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    background: white;
}

.tier-card:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.tier-card.selected {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.tier-card h3 {
    font-size: 18px;
    color: #1e40af;
    margin-bottom: 8px;
    font-weight: 700;
}

.tier-card .price {
    font-size: 28px;
    font-weight: 700;
    color: #059669;
    margin-bottom: 4px;
}

.tier-card .price-label {
    font-size: 12px;
    color: #6b7280;
}

/* Admin page: .tier-grid > .tier-card */
.tier-grid .tier-card {
    padding: 24px;
    cursor: default;
    text-align: left;
    background: #f9fafb;
}

.tier-grid .tier-card:hover {
    transform: none;
    box-shadow: none;
    border-color: #e5e7eb;
}

.tier-grid .tier-card h3 {
    margin-bottom: 16px;
}

/* ====================================================
   ADD-ON ITEMS — scoped by parent container
   ==================================================== */

/* Calculator page: standalone .addon-item (flex row) */
.addon-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: white;
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid #e5e7eb;
}

.addon-info {
    flex: 1;
}

.addon-name {
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.addon-price {
    font-size: 14px;
    color: #059669;
    font-weight: 600;
}

.addon-input {
    width: 80px;
    margin-left: 16px;
}

/* Admin page: .addon-list > .addon-item (grid edit row) */
.addon-list .addon-item {
    border: 2px solid #e5e7eb;
    background: #f9fafb;
    display: grid;
    grid-template-columns: 28px 1fr 1fr 200px auto;
    gap: 16px;
    align-items: end;
    margin-bottom: 0;
    justify-content: unset;
}

/* ====================================================
   CALCULATOR PAGE (index.php)
   ==================================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    color: white;
    padding: 40px;
    text-align: center;
    position: relative;
}

.admin-link {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s;
}

.admin-link:hover {
    background: rgba(255, 255, 255, 0.3);
}

.header h1 {
    font-size: 32px;
    margin-bottom: 8px;
    font-weight: 700;
}

.header p {
    font-size: 16px;
    opacity: 0.9;
}

.content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 0;
}

.calculator-section {
    padding: 40px;
    background: #f9fafb;
}

.summary-section {
    padding: 40px;
    background: white;
    border-left: 1px solid #e5e7eb;
}

.tier-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
    flex: 1;
}

.summary-card {
    background: #f9fafb;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-label {
    color: #6b7280;
    font-size: 14px;
}

.summary-value {
    font-weight: 700;
    color: #374151;
    font-size: 16px;
}

.total-section {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    border-radius: 12px;
    padding: 24px;
    margin-top: 24px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
}

.total-label {
    font-size: 16px;
    opacity: 0.9;
}

.total-value {
    font-size: 24px;
    font-weight: 700;
}

.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 24px;
}

.features-list {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-top: 16px;
    border: 1px solid #e5e7eb;
}

.features-list h4 {
    font-size: 14px;
    color: #1e40af;
    margin-bottom: 12px;
    font-weight: 700;
}

.features-list ul {
    list-style: none;
}

.features-list li {
    padding: 6px 0;
    color: #6b7280;
    font-size: 13px;
}

.features-list li:before {
    content: "✓ ";
    color: #059669;
    font-weight: bold;
    margin-right: 8px;
}

.info-box {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}

.info-box p {
    color: #78350f;
    font-size: 14px;
    line-height: 1.6;
}

.admin-override-input {
    width: 150px;
    padding: 6px 10px;
    border: 2px solid #f59e0b;
    border-radius: 6px;
    font-size: 13px;
    background: #fffbeb;
    transition: all 0.3s;
}

.admin-override-input:focus {
    outline: none;
    border-color: #d97706;
    background: #fef3c7;
}

.admin-badge {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(34, 197, 94, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.custom-line-item {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid #fbbf24;
    align-items: center;
}

.custom-line-item input[type="text"],
.custom-line-item input[type="number"] {
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
}

.custom-line-item input:focus {
    outline: none;
    border-color: #f59e0b;
}

.loaded-quote-banner {
    background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.loaded-quote-banner h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.loaded-quote-banner p {
    font-size: 13px;
    opacity: 0.9;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

/* ====================================================
   ADMIN PAGE (admin.php)
   ==================================================== */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-container h1 {
    text-align: center;
    color: #1e40af;
    margin-bottom: 32px;
}

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.admin-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    color: white;
    padding: 30px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header h1 {
    font-size: 28px;
}

.admin-content {
    padding: 40px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
    border-bottom: 2px solid #e5e7eb;
}

.tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab.active {
    color: #1e40af;
    border-bottom-color: #3b82f6;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tier-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.addon-list {
    display: grid;
    gap: 16px;
}

.drag-handle {
    cursor: grab;
    color: #9ca3af;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    padding-bottom: 10px;
}

.drag-handle:active {
    cursor: grabbing;
}

[data-id].dragging {
    opacity: 0.45;
}

[data-id].drag-over {
    border-color: #3b82f6 !important;
    background: #eff6ff !important;
}

.quotes-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

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

.quotes-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.quotes-table tr:hover {
    background: #f9fafb;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-essential {
    background: #dbeafe;
    color: #1e40af;
}

.badge-professional {
    background: #d1fae5;
    color: #065f46;
}

.badge-enterprise {
    background: #fce7f3;
    color: #9f1239;
}

.add-new-btn {
    margin-bottom: 20px;
}

.quote-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.quote-row:hover {
    background: #f0f9ff !important;
}

.quote-row.expanded {
    background: #eff6ff;
}

.quote-detail-row td {
    padding: 0 !important;
    border-bottom: 2px solid #3b82f6;
}

.quote-detail-content {
    padding: 20px 24px;
    background: #f8fafc;
    border-top: 1px solid #dbeafe;
}

.expand-icon {
    display: inline-block;
    transition: transform 0.2s;
    margin-right: 8px;
    font-size: 10px;
    color: #9ca3af;
}

.expand-icon.open {
    transform: rotate(90deg);
    color: #3b82f6;
}

/* ====================================================
   PDF TEMPLATE EDITOR
   ==================================================== */
.pdf-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.pdf-editor-layout {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 24px;
    align-items: start;
}

/* Left nav */
.pdf-section-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    position: sticky;
    top: 20px;
}

.pdf-nav-btn {
    padding: 10px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
    white-space: nowrap;
}

.pdf-nav-btn:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.pdf-nav-btn.active {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
    font-weight: 600;
}

/* Right content pane */
.pdf-editor-content {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 28px;
    min-height: 400px;
}

.pdf-section-header {
    margin-bottom: 22px;
    padding-bottom: 14px;
    border-bottom: 2px solid #e5e7eb;
}

.pdf-section-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 4px;
}

.pdf-section-header p {
    font-size: 13px;
    color: #6b7280;
}

/* Field group */
.pdf-field-group {
    margin-bottom: 18px;
}

.pdf-field-group label {
    display: block;
    font-weight: 600;
    color: #374151;
    font-size: 13px;
    margin-bottom: 5px;
}

.pdf-field-note {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 5px;
}

.pdf-field-note code {
    background: #e5e7eb;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 11px;
}

.pdf-field-group input[type="text"],
.pdf-field-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s;
    resize: vertical;
}

.pdf-field-group input[type="text"]:focus,
.pdf-field-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

/* Two-column field layout for contact */
.pdf-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
}

/* Card list (services / FAQ) */
.pdf-list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pdf-list-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s;
}

.pdf-list-card.dragging   { opacity: 0.45; }
.pdf-list-card.drag-over  { border-color: #3b82f6 !important; background: #eff6ff; }

.pdf-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    cursor: default;
}

.pdf-card-header .drag-handle {
    font-size: 18px;
    padding-bottom: 0;
    color: #9ca3af;
    flex-shrink: 0;
}

.pdf-card-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-card-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
}

.pdf-card-toggle:hover { background: #e5e7eb; }

.pdf-card-body {
    padding: 16px;
}

/* SLA edit table */
.sla-edit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sla-edit-table th {
    background: #f3f4f6;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.sla-edit-table td {
    padding: 6px 8px;
    border: 1px solid #e5e7eb;
}

.sla-edit-table td input[type="text"] {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    background: white;
}

.sla-edit-table td input[type="text"]:focus {
    outline: none;
    border-color: #3b82f6;
}

/* ====================================================
   RESPONSIVE
   ==================================================== */
@media (max-width: 968px) {
    .content {
        grid-template-columns: 1fr;
    }

    .summary-section {
        border-left: none;
        border-top: 1px solid #e5e7eb;
    }

    .tier-cards {
        grid-template-columns: 1fr;
    }

    .tier-grid {
        grid-template-columns: 1fr;
    }

    .addon-list .addon-item {
        grid-template-columns: 1fr;
    }
}
