/**
 * Hex Form Component System Styles
 *
 * Styles for [hex-form], [fieldset], [field] shortcode system
 */

/* ==========================================================================
   Form Container
   ========================================================================== */

.hex-form {
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 30px;
}

.hex-form-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 24px 0;
    padding: 0 0 16px 0;
    border-bottom: 1px solid #eee;
    color: #333;
}

.hex-form-fields {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ==========================================================================
   Fieldset Grouping
   ========================================================================== */

.hex-form-fieldset {
    border: none;
    margin: 0 0 24px 0;
    padding: 0;
}

.hex-form-fieldset:last-child {
    margin-bottom: 0;
}

.hex-form-legend {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    padding: 0;
}

.hex-fieldset-fields {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 20px;
}

/* Single field outside fieldset */
.hex-form-fields > .hex-field {
    margin-bottom: 20px;
}

.hex-form-fields > .hex-field:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   Field Components
   ========================================================================== */

.hex-field {
    display: flex;
    flex-direction: column;
}

/* Full-width field types */
.hex-field--textarea,
.hex-field--full-width {
    grid-column: 1 / -1;
}

/* Field Label */
.hex-field-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: #333;
}

.hex-field-required {
    color: #d63638;
    margin-left: 2px;
}

.hex-field-optional {
    color: #666;
    font-weight: normal;
    font-size: 13px;
    margin-left: 4px;
}

/* Input Elements - base class used by all field types */
.hex-field-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.hex-field-input::placeholder {
    color: #999;
}

.hex-field-input:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Textarea specific (adds to .hex-field-input) */
textarea.hex-field-input,
.hex-field-input.hex-field-textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.5;
}

/* Select specific (adds to .hex-field-input) */
select.hex-field-input,
.hex-field-input.hex-field-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ==========================================================================
   Error States
   ========================================================================== */

.hex-field-error {
    display: block;
    color: #d63638;
    font-size: 12px;
    margin-top: 5px;
    min-height: 0;
}

.hex-field-error:empty {
    display: none;
}

.hex-field.has-error .hex-field-input {
    border-color: #d63638;
}

.hex-field.has-error .hex-field-input:focus {
    box-shadow: 0 0 0 1px #d63638;
}

/* ==========================================================================
   Form Actions
   ========================================================================== */

.hex-form-actions {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.hex-form-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    background: #2271b1;
    color: #fff;
    min-width: 120px;
}

.hex-form-submit:hover {
    background: #135e96;
}

.hex-form-submit:active {
    transform: scale(0.98);
}

.hex-form-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.hex-form-submit-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.hex-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: hex-spin 0.6s linear infinite;
}

@keyframes hex-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Form Messages
   ========================================================================== */

.hex-form-messages {
    margin-top: 16px;
}

.hex-form-messages:empty {
    display: none;
}

.hex-form-message {
    padding: 14px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

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

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

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .hex-form {
        padding: 20px;
        margin: 0 10px;
    }

    .hex-fieldset-fields {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .hex-form-submit {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .hex-form {
        padding: 16px;
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin: 0;
    }

    .hex-form-title {
        font-size: 20px;
    }
}

/* ==========================================================================
   Conditional Fields
   ========================================================================== */

.hex-field[data-show-when-field] {
    transition: opacity 0.2s ease, max-height 0.2s ease;
}

.hex-field[data-show-when-field][style*="display: none"] {
    opacity: 0;
}

/* ==========================================================================
   Custom Composite Fields
   ========================================================================== */

/* Phone Input (split format) */
.hex-phone-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hex-phone-inputs span {
    color: #666;
    font-size: 14px;
}

.hex-phone-inputs .hex-phone-area {
    width: 60px;
    text-align: center;
}

.hex-phone-inputs .hex-phone-part {
    width: 70px;
    text-align: center;
}

/* Date Input (split format) */
.hex-date-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hex-date-inputs span {
    color: #666;
    font-size: 14px;
}

.hex-date-inputs .hex-date-part {
    width: 80px;
    text-align: center;
}

/* Checkbox Group */
.hex-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hex-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.hex-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* File Upload Zone */
.hex-upload-zone {
    position: relative;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    transition: border-color 0.2s, background-color 0.2s;
    cursor: pointer;
}

.hex-upload-zone:hover {
    border-color: #2271b1;
    background-color: #f8fafc;
}

.hex-upload-zone.dragover {
    border-color: #2271b1;
    background-color: #e8f4fc;
}

.hex-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.hex-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #666;
}

.hex-upload-placeholder svg {
    color: #999;
}

.hex-upload-text {
    font-weight: 500;
    color: #333;
}

.hex-upload-hint {
    font-size: 12px;
    color: #888;
}

.hex-upload-preview {
    text-align: center;
}

.hex-preview-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.hex-preview-file {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #666;
}

.hex-remove-file {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    margin-top: 10px;
}

.hex-remove-file:hover {
    background: #c82333;
}

.hex-file-list {
    margin-top: 12px;
}

.hex-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 13px;
}

/* Hint Text */
.hex-field-hint {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    line-height: 1.4;
}

/* Optional Label */
.hex-field-optional {
    color: #888;
    font-weight: normal;
    font-size: 13px;
}

/* ==========================================================================
   Auth Panel Layout
   ========================================================================== */

.hex-auth-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

.hex-auth-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.hex-auth-panel {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 30px;
}

.hex-auth-panel .hex-form {
    max-width: none;
    border: none;
    padding: 0;
}

.hex-form-links {
    margin-top: 16px;
    text-align: center;
}

.hex-form-links a {
    color: #2271b1;
    text-decoration: none;
    font-size: 14px;
}

.hex-form-links a:hover {
    text-decoration: underline;
}

.hex-form-privacy {
    margin-top: 16px;
    font-size: 12px;
    color: #666;
    line-height: 1.5;
}

.hex-form-privacy a {
    color: #2271b1;
}

@media (max-width: 768px) {
    .hex-auth-panels {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Form Modifiers
   ========================================================================== */

.hex-form--registration .hex-fieldset-fields,
.hex-form--address .hex-fieldset-fields {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 768px) {
    .hex-form--registration .hex-fieldset-fields,
    .hex-form--address .hex-fieldset-fields {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   WooCommerce My Account Auth Columns
   ========================================================================== */

.hex-auth-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    max-width: 900px;
    margin: 0 auto;
}

.hex-auth-column {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 30px;
}

.hex-auth-column h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 20px 0;
    padding: 0 0 16px 0;
    border-bottom: 1px solid #eee;
    color: #333;
}

.hex-auth-column .hex-form {
    max-width: none;
    border: none;
    padding: 0;
    background: none;
}

/* Remember me row */
.hex-form-row--remember {
    margin-top: 16px;
}

.hex-form-row--remember .hex-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.hex-form-row--remember input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Lost password link */
.hex-form-lost-password {
    margin-top: 16px;
    font-size: 14px;
}

.hex-form-lost-password a {
    color: #2271b1;
    text-decoration: none;
}

.hex-form-lost-password a:hover {
    text-decoration: underline;
}

/* Form notices */
.hex-form-notice {
    padding: 12px 16px;
    background: #f0f6fc;
    border: 1px solid #c8d7e8;
    border-radius: 4px;
    font-size: 14px;
    color: #1e3a5f;
    margin-top: 16px;
}

/* Extra hook content */
.hex-form-extra {
    margin-top: 16px;
}

@media (max-width: 768px) {
    .hex-auth-columns {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .hex-auth-column {
        padding: 20px;
    }
}

/* ==========================================================================
   Single Auth Form (Lost Password, Reset Password)
   ========================================================================== */

.hex-auth-single {
    max-width: 480px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 30px;
}

.hex-auth-single h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: #333;
}

.hex-auth-single .hex-form {
    max-width: none;
    border: none;
    padding: 0;
    background: none;
}

.hex-form-intro {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.hex-form-back-link {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eee;
    font-size: 14px;
}

.hex-form-back-link a {
    color: #2271b1;
    text-decoration: none;
}

.hex-form-back-link a:hover {
    text-decoration: underline;
}

@media (max-width: 480px) {
    .hex-auth-single {
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

/* ==========================================================================
   Support Tickets List (My Account)
   ========================================================================== */

.hex-support-tickets {
    margin-top: 20px;
}

.hex-tickets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.hex-tickets-header h2 {
    margin: 0;
}

/* Empty state */
.hex-empty-state {
    padding: 40px 20px;
    text-align: center;
    background: #f9f9f9;
    border-radius: 4px;
}

.hex-empty-state p {
    margin: 0 0 10px;
    color: #666;
}

.hex-empty-state p:last-child {
    margin-bottom: 0;
}

/* Tickets table */
.hex-table {
    width: 100%;
    border-collapse: collapse;
}

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

.hex-table th {
    background: #f9f9f9;
    font-weight: 600;
}

/* Status badges */
.hex-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
}

.hex-badge--open {
    background: #fff3cd;
    color: #856404;
}

.hex-badge--pending {
    background: #cce5ff;
    color: #004085;
}

.hex-badge--resolved,
.hex-badge--closed {
    background: #d4edda;
    color: #155724;
}

/* Buttons */
.hex-btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s;
}

.hex-btn--primary {
    background: #2271b1;
    color: #fff;
}

.hex-btn--primary:hover {
    background: #135e96;
    color: #fff;
}

/* Responsive table */
@media (max-width: 768px) {
    .hex-table thead {
        display: none;
    }

    .hex-table tr {
        display: block;
        margin-bottom: 16px;
        border: 1px solid #eee;
        border-radius: 4px;
        padding: 12px;
    }

    .hex-table td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #f5f5f5;
    }

    .hex-table td:last-child {
        border-bottom: none;
    }

    .hex-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #666;
    }
}

/* ==========================================================================
   Submit Ticket Form (My Account)
   ========================================================================== */

.hex-submit-ticket {
    margin-top: 20px;
}

.hex-submit-ticket h2 {
    margin: 0 0 10px;
}

.hex-submit-ticket .hex-form-intro {
    color: #666;
    margin-bottom: 20px;
}

.hex-submit-ticket .hex-form {
    max-width: none;
    border: none;
    padding: 0;
    background: none;
}
